Socket
Book a DemoInstallSign in
Socket

methodist

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

methodist

HTTP method matching

Source
npmnpm
Version
1.0.3
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

methodist

NPM version build status Test coverage Downloads js-standard-style

HTTP method matching.

Installation

$ npm install methodist

Usage

const methodist = require('methodist')
const wayfarer = require('wayfarer')
const http = require('http')

const router = wayfarer()
const server = http.createServer((req, res) => {
  router.on('/hello', methodist(req, {
    all: params => console.log('any route matches'),
    get: params => console.log('get')
  }))
})

server.listen(1337)

API

methodist(method, routes)

Call a callback based on method or req.method. Routes is an object where the keys are one of methods, all or any. all and any are checked before other methods. Methods are normalized to lowercase.

See Also

License

MIT

Keywords

router

FAQs

Package last updated on 27 Jul 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts