0.3.0 • Published 10 years ago

fun-chain-dispatch v0.3.0

Weekly downloads
2
License
-
Repository
github
Last release
10 years ago

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 )

Todo:

  • Support sinatra-style url patterns and url "params" extraction, probably using the path-to-regexp module
0.3.0

10 years ago

0.2.0

10 years ago

0.1.0

11 years ago