Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/routes-router-mount
routes-router-mount
https://github.com/binocarlos/routes-router-mount
Last synced: 11 days ago
JSON representation
routes-router-mount
- Host: GitHub
- URL: https://github.com/binocarlos/routes-router-mount
- Owner: binocarlos
- Created: 2014-10-06T22:35:37.000Z (about 10 years ago)
- Default Branch: master
- Last Pushed: 2014-10-06T22:37:42.000Z (about 10 years ago)
- Last Synced: 2024-10-04T13:48:33.433Z (about 2 months ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
routes-router-mount
===================[![Travis](http://img.shields.io/travis/binocarlos/routes-router-mount.svg?style=flat)](https://travis-ci.org/binocarlos/routes-router-mount)
Call `prefix` on a [routes-router](https://github.com/Raynos/routes-router) and remove the prefix from the req.url
## install
```bash
$ npm install routes-router-mount
```## usage
Wrap a routes-router to get a `mount` method:
```js
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:
```bash
$ 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