httpdispatcher - basic dispatcher for node.js
httpdispatcher is a simple class allows developer to have a clear dispatcher for dynamic pages and static resources. Classes http.ServerRequest and http.ServerResponse earns new params property containing a map of received HTTP parameters. Using httpdispatcher is pretty simple:
var HttpDispatcher = ; var http = ; var dispatcher = ; dispatcher; dispatcher; dispatcher; dispatcher; dispatcher; dispatcher; dispatcher; http; /* GET /page1 => 'Page One' POST /page2 => 'Page Two' GET /page3 => 404 GET /resources/images-that-exists.png => Image resource GET /resources/images-that-does-not-exists.png => 404 */
request and response
Every listeners is called with two parameters request
and response
.
Request object is an instance of http.ClientRequest
with some custom properties:
- bodyBuffer :
Buffer
(available only on POST request) - body : String (available only on POST request)
- params : Object
Response object is an instance of http.ServerResponse
.