Skip to content

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages