0.1.0 • Published 10 years ago

node_dispatcher v0.1.0

Weekly downloads
3
License
BSD-2-Clause
Repository
github
Last release
10 years ago

node-dispatcher

Simple dispatcher with Node js.

Installation

If you use npm, simply do npm install node-dispatcher.

Examples

var static_hnd = [
	{ url:'/favicon.ico', file:'/favicon.ico'},
	{ pattern: '\/css($|\/)', dir:'/assets/css'},
	{ pattern: '\/js($|\/)', dir:'/assets/js'},
	{ pattern: '\/img($|\/)', dir:'/assets/img'}
];

var router = new (require('node-dispatcher').router)(static_hnd),
	dispatcher = require('node-dispatcher').dispatcher;

router.add('/:controller/:action/:id');

var http = require("http");
var server = http.Server(function (request, response) {

	var d = new dispatcher();
	d.dispatch(request
			, response
			, router);


}).listen(3000);

Example application

node test/index.js