HTTP dispatch functions to use with fun-chain
JavaScript
Switch branches/tags
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
README.md
index.js
package.json
test.js

README.md

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 )