simple-path-router

A simple path-only router

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
simple-path-router
101.1.09 years ago10 years agoMinified + gzip package size for simple-path-router in KB

Readme

simple-path-router
Build Status Coverage Status
A simple path-only router

Example

'use strict';

var PathRouter = require('simple-path-router');

var router = new PathRouter()
	.when('/', serveWeb)
	.when('/api', serveApi);

require('http')
	.createServer(router.dispatch)
	.listen(10000);

function serveWeb (req, res) {
	console.log('web!');
	res.statusCode = 200;
	res.end();
}

function serveApi (req, res) {
	console.log('api!');
	res.statusCode = 200;
	res.end();
}