Simple framework independent routing middleware for node.js.
This was build as a dropin replacement for the routing middleware in express.js.
pfadfinder should do the same, but in a decoupled way so it can be used
with other middleware frameworks, too.
http = require 'http'pfadfinder = require 'pfadfinder'router = pfadfinderrouterget '/hello' resend 'hello world'routerget '/hello/:name' resend "hello "routerpost '/hello/:name' resend "post to "server = httpcreateServer routermiddlewareserverlisten 8888
You can find this example and another in the
pfadfinder can be composed with other middlewares.
For example if no route is matched, pfadfinder calls it own
Composer merges an array of middlewares
into own middleware.
To present a default
404 if a route was not found it is possible to do this:
composer = require 'composer'router = pfadfinder=reswriteHead 404resend 'not found'composition = composer routermiddlewarenotFoundserver = httpcreateServer compositionserverlisten 8888```coffeescript