2.1.0 • Published 10 years ago

methodist v2.1.0

Weekly downloads
9
License
MIT
Repository
github
Last release
10 years ago

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

2.1.0

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago