{
  "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        = require('connect')\nvar methodOverride = require('method-override')\n\n// override with different headers; last one takes precedence\napp.use(methodOverride('X-HTTP-Method'))          // Microsoft\napp.use(methodOverride('X-HTTP-Method-Override')) // Google/GData\napp.use(methodOverride('X-Method-Override'))      // IBM\n```\n\n### custom logic\n\nYou can implement any kind of custom logic with a function for the `getter`. The following\nimplements the logic for looking in `req.body` that was in `method-override` 1:\n\n```js\nvar bodyParser     = require('body-parser')\nvar connect        = require('connect')\nvar methodOverride = require('method-override')\n\napp.use(bodyParser.urlencoded())\napp.use(methodOverride(function(req, res){\n  if (req.body && typeof req.body === 'object' && '_method' in req.body) {\n    // look in urlencoded POST bodies and delete it\n    var method = req.body._method\n    delete req.body._method\n    return method\n  }\n}))\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2014 Jonathan Ong me@jongleberry.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/expressjs/method-override/issues"
  },
  "homepage": "https://github.com/expressjs/method-override",
  "_id": "method-override@2.0.2",
  "_shasum": "00531278c79789640bf27e97e26a3a5a1f7cca73",
  "_from": "method-override@2.0.2",
  "_resolved": "https://registry.npmjs.org/method-override/-/method-override-2.0.2.tgz"
}
