Skip to content

binocarlos/routes-router-mount

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

routes-router-mount

Travis

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

About

routes-router-mount

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published