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

latest
Source
npmnpm
Version
2.1.0
Version published
Maintainers
1
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 server = http.createServer((req, res) => {
  const router = wayfarer()
  const method = methodist(req, router)

  router.on('/hello', method({
    all: params => console.log('any route matches'),
    get: params => console.log('get')
  }))
})

server.listen(1337)

API

methodist(method, default, routes)

Uses curry to allow reusable constuctors.

  • method: methods are either an HTTP verb or http.ClientRequest class. Methods are lowercased before matched.
  • default: default() is called if no methods match. Checks if default.default() exists for easy integration with wayfarer.
  • routes: Routes is an object where the keys are one of methods, all or any. all and any are called if no other method matches.

See Also

License

MIT

Keywords

router

FAQs

Package last updated on 02 Sep 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