Package Exports
- server-router
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (server-router) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
server-router 
Server router.
Usage
const serverRouter = require('server-router')
const http = require('http')
const router = serverRouter('/404')
router.on('/hello', function (req, res) {
res.end('hello world')
})
router.on('/:username', {
get: function (req, res, params) {
res.end('username is ' + params.username)
},
delete: function (req, res, params) {
res.end('username ' + params.username + 'will be deleted')
}
})
http.createServer(router).listen()
API
router = serverRouter(default)
Create a new router with a default path. If no default path is set, the router will crash if an unknown path is encountered.
router.on(route, callback|obj)
Attach a callback to a route. Callback can be either a function, which is
registered as GET
or an object containing functions, with valid HTTP methods
as keys.
router(req, res, params, ...?)
Match a route on a router. Additional arguments can be passed to the matched
function. Matched routes have a signature of (req, res, params, ...?)
.
Installation
$ npm install server-router