routes-router-mount
v0.1.0
Published
Call routes-router.prefix and remove the prefix from the req.url
Downloads
3
Readme
routes-router-mount
Call prefix
on a routes-router and remove the prefix from the req.url
install
$ npm install routes-router-mount
usage
Wrap a routes-router to get a mount
method:
var http = require('http')
var mount = require('routes-router-mount')
var Router = require('routes-router')
var router = mount(Router())
router.prefix('/apples', function(req, res){
res.end(req.url)
})
router.mount('/apples2', function(req, res){
res.end(req.url)
})
http.createServer(router).listen(8080)
Then GET some urls:
$ curl -L http://127.0.0.1:8080/apples/grannysmith
$ curl -L http://127.0.0.1:8080/apples2/grannysmith
Would print:
/apples/grannysmith
/grannysmith
licence
MIT