0.0.1 • Published 9 years ago
http-router-fn v0.0.1
http-router-fn
Creates a middleware handler that can organize other handlers into routes. Router is the dispatch function as well.
Install:
npm i http-router-fn
Example:
var http = require('http');
var createRouter = require('http-router-fn');
var router = createRouter();
router.get('/', function(req, res) {
res.end('Index page!');
});
http.createServer(router).listen(80);
API:
- createRouter() - Creates a new router
Options:
- pattern - Can be a string or regex object. Also support express-style token strings.
- mw - Any number of middleware handlers may be placed in front of the handler. They will executed before the handler.
- handler - An express-style handler.