Skip to content

trekjs/method-override

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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'
})

Badges

Build Status codecov


fundon.me  ·  GitHub @fundon  ·  Twitter @_fundon

About

Override HTTP verbs

Resources

License

Stars

Watchers

Forks

Packages

No packages published