trek-method-override
Method Overrider Middleware for Trek.js
Installation
$ npm install trek-method-override --save
Examples
'use strict'
const Engine = require('trek-engine')
const bodyParser = require('trek-body-parser')
const methodOverride = require('trek-method-override')
async function start () {
const app = new Engine()
app.use(bodyParser())
app.use(methodOverride())
app.use(ctx => {
ctx.res.body = {
method: ctx.req.method,
originalMethod: ctx.req.originalMethod
}
})
app.on('error', (err, ctx) => {
console.log(err)
})
app.run(3000)
}
start().catch(console.log)
API
methodOverride({
methods: ['POST'],
tokenLookup: 'header:X-HTTP-Method-Override'
})