47 lines
7.2 KiB
JSON
47 lines
7.2 KiB
JSON
|
{
|
||
|
"name": "method-override",
|
||
|
"description": "Override HTTP verbs",
|
||
|
"version": "2.0.2",
|
||
|
"author": {
|
||
|
"name": "Jonathan Ong",
|
||
|
"email": "me@jongleberry.com",
|
||
|
"url": "http://jongleberry.com"
|
||
|
},
|
||
|
"contributors": [
|
||
|
{
|
||
|
"name": "Douglas Christopher Wilson",
|
||
|
"email": "doug@somethingdoug.com"
|
||
|
}
|
||
|
],
|
||
|
"license": "MIT",
|
||
|
"repository": {
|
||
|
"type": "git",
|
||
|
"url": "git://github.com/expressjs/method-override"
|
||
|
},
|
||
|
"dependencies": {
|
||
|
"methods": "1.0.1",
|
||
|
"parseurl": "1.0.1",
|
||
|
"vary": "0.1.0"
|
||
|
},
|
||
|
"devDependencies": {
|
||
|
"istanbul": "0.2.10",
|
||
|
"mocha": "~1.20.0",
|
||
|
"supertest": "~0.13.0"
|
||
|
},
|
||
|
"engines": {
|
||
|
"node": ">= 0.8.0"
|
||
|
},
|
||
|
"scripts": {
|
||
|
"test": "mocha --reporter dot test/",
|
||
|
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/",
|
||
|
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec test/"
|
||
|
},
|
||
|
"readme": "# method-override\n\n[![NPM version](https://badge.fury.io/js/method-override.svg)](http://badge.fury.io/js/method-override)\n[![Build Status](https://travis-ci.org/expressjs/method-override.svg?branch=master)](https://travis-ci.org/expressjs/method-override)\n[![Coverage Status](https://img.shields.io/coveralls/expressjs/method-override.svg?branch=master)](https://coveralls.io/r/expressjs/method-override)\n\nLets you use HTTP verbs such as PUT or DELETE in places where the client doesn't support it.\n\n## Install\n\n```sh\n$ npm install method-override\n```\n\n## API\n\n**NOTE** It is very important that this module is used **before** any module that\nneeds to know the method of the request (for example, it _must_ be used prior to\nthe `csurf` module).\n\n### methodOverride(getter, options)\n\nCreate a new middleware function to override the `req.method` property with a new\nvalue. This value will be pulled from the provided `getter`.\n\n- `getter` - The getter to use to look up the overridden request method for the request. (default: `X-HTTP-Method-Override`)\n- `options.methods` - The allowed methods the original request must be in to check for a method override value. (default: `['POST']`)\n\nIf the found method is supported by node.js core, then `req.method` will be set to\nthis value, as if it has originally been that value. The previous `req.method`\nvalue will be stored in `req.originalMethod`.\n\n#### getter\n\nThis is the method of getting the override value from the request. If a function is provided,\nthe `req` is passed as the first argument, the `res as the second argument and the method is\nexpected to be returned. If a string is provided, the string is used to look up the method\nwith the following rules:\n\n- If the string starts with `X-`, then it is treated as the name of a header and that header\n is used for the method override. If the request contains the same header multiple times, the\n first occurrence is used.\n- All other strings are treated as a key in the URL query string.\n\n#### options.methods\n\nThis allows the specification of what methods(s) the request *MUST* be in in order to check for\nthe method override value. This defaults to only `POST` methods, which is the only method the\noverride should arrive in. More methods may be specified here, but it may introduce security\nissues and cause weird behavior when requests travel through caches. This value is an array\nof methods in upper-case. `null` can be specified to allow all methods.\n\n## Examples\n\n### override using a header\n\nTo use a header to override the method, specify the header name\nas a string argument to the `methodOverride` function. To then make\nthe call, send a `POST` request to a URL with the overridden method\nas the value of that header.\n\n```js\nvar connect = require('connect')\nvar methodOverride = require('method-override')\n\n// override with the X-HTTP-Method-Override header in the request\napp.use(methodOverride('X-HTTP-Method-Override'))\n```\n\nExample call with header override using `curl`:\n\n```\ncurl -XPOST -H'X-HTTP-Method-Override: DELETE' --verbose http://localhost:3000/resource\n> POST /resource HTTP/1.1\n> Host: localhost:3000\n> X-HTTP-Method-Override: DELETE\n>\nCannot DELETE /resource\n```\n\n### override using a query value\n\nTo use a query string value to override the method, specify the query\nstring key as a string argument to the `methodOverride` function. To\nthen make the call, send a `POST` request to a URL with the overridden\nmethod as the value of that query string key.\n\n```js\nvar connect = require('connect')\nvar methodOverride = require('method-override')\n\n// override with POST having ?_method=DELETE\napp.use(methodOverride('_method'))\n```\n\nExample call with query override using `curl`:\n\n```\ncurl -XPOST --verbose http://localhost:3000/resource?_method=DELETE\n> POST /resource?_method=DELETE HTTP/1.1\n> Host: localhost:3000\n>\nCannot DELETE /resource?_method=DELETE\n```\n\n### multiple format support\n\n```js\nvar connect = requi
|
||
|
"readmeFilename": "README.md",
|
||
|
"bugs": {
|
||
|
"url": "https://github.com/expressjs/method-override/issues"
|
||
|
},
|
||
|
"_id": "method-override@2.0.2",
|
||
|
"_from": "method-override@"
|
||
|
}
|