Full method override for koajs, enabling developer to launch PUT/DELETE/GET/POST request from HTTP form or links.
npm install koamethodoverride
Configuration your server as follows:
var koa = ;var bodyParser = ;var override = ;var server = ;server;server;server;
Now you can write your form as follows:
<!-- something more -->
Or link like this:
The middle ware will take 3 part of a request into consideration:
- request.query._method(from query string)
- "x-http-method-override" header(case sensitive)
The priority of above is request.body > request.query > "x-http-method-override" header.
If the override method from a higher priority level exists but the value is not within:
then the middleware will search for lower level override methods, if such don't exist or all go wrong, then the middleware will simply use the original method and will not raise exception.