route-prefix
add a prefix in front of a router
example
Suppose you have a router.js file:
var routes = ;module {var r = ;r;r;return r;};
Now you can mount that router at a prefix.
In this case, the prefix is /xyz
:
var http = ;var prefix = ;var router = ;var server = http;server;
methods
var prefix =
var prouter = prefix(pre, router)
Return a new router prouter
that mounts the
routes router
at the prefix string pre
.
The given router
just needs to have a router.match(url)
function that
returns a falsy value when the route doesn't match. The
routes package happens to supply that
interface but you can use whatever module you want and the enumerable properties
are copied from router
to create the prouter
copy.
install
With npm do:
npm install route-prefix
license
MIT