fun-chain-dispatch

0.3.0 • Public • Published

Builds functions that fit into a chain intended to be used with node's http.createServer method.

E.g.

http.createServer(chain(
  [ dispatch('get', '/foo', serveFoo)
  , dispatch('get', '/bar', serveBar)
  , dispatch(matchesStaticFile, serveStaticFile)
  , dispatch(serveNotFound)
  ]))

"Porcelain" API:

dispatch('get', '/foo', foo)
dispatch(matcherFn, handler)
dispatch(handler)

"Plumbing" API:

dispatch.ifMatchElseNext(
    dispatch.matchers.forMethodAndPathname('get', '/foo')
  , serveFoo )

dispatch.ifMatchElseNext(
    matchesStaticFile
  , serveStaticFile )

dispatch.ifMatchElseNext(
    dispatch.matchers.any
  , serveNotFound )

Readme

Keywords

none

Package Sidebar

Install

npm i fun-chain-dispatch

Weekly Downloads

1

Version

0.3.0

License

BSD

Last publish

Collaborators

  • quackingduck