Skip to content

method override middleware for koa

License

Notifications You must be signed in to change notification settings

eggjs/koa-override

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-override

NPM version npm download CI Coverage

Method override middleware. Let you use HTTP verbs such as PUT or DELETE in places where the client doesn't support it.

Refactor from koa-override-method#5

Install

npm install koa-override --save

Usage

import bodyParser from 'koa-bodyparser';
import override from 'koa-override';

app.use(bodyParser());
app.use(override());

API

const mw = override([options])

If body exists, check body._method first. Otherwise check X-HTTP-Method-Override header.

If there is no override parameter, then it's simply this.request.method. You shouldn't use this unless you know you're using override.

  • options.allowedMethods = [ 'POST' ] Only allowed override method on POST request.

License

MIT

Contributors

Contributors

Made with contributors-img.