Skip to content

Commit

Permalink
fixing typos
Browse files Browse the repository at this point in the history
  • Loading branch information
teknopaul committed Jul 15, 2011
1 parent 33d2bdd commit e5b2d99
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions README
Original file line number Original file line Diff line number Diff line change
@@ -1,9 +1,13 @@
ServletsFilter style reques chaining. ServletsFilter style request chaining.


This is very simple single file modeul but provides a nice structure for webapps allowing you to introduce configurable aspects to each requires. This is very simple single file module, but provides a nice structure for webapps allowing you to introduce configurable aspects to each request.


The chain is configured in code, you can externalize it if you need. The chain is configured in code, you can externalize it if you need.


Usage:

First load a set of filters

var attributesFilter = require("../server/attributes-filter"), var attributesFilter = require("../server/attributes-filter"),
logRequestFilter = require("../server/log-request-filter") logRequestFilter = require("../server/log-request-filter")
serverHeaderFilter = require("../server/server-header-filter"), serverHeaderFilter = require("../server/server-header-filter"),
Expand All @@ -23,7 +27,7 @@ var chainModules = [
var chain = new FilterChain(chainModules); var chain = new FilterChain(chainModules);




Then ins a server start the chain with its execute() method, passing the request and response. Then, in a server start, the chain with it's execute() method, passing the request and response.




http.createServer(function(request, response) { http.createServer(function(request, response) {
Expand All @@ -35,10 +39,10 @@ http.createServer(function(request, response) {
}).listen(8000); }).listen(8000);





That's it, nothing special, but a usefull design pattern.
Filters look identical to Java Servlets filters




Filters look identical to Java Servlets filters.


var parse = require('url').parse; var parse = require('url').parse;


Expand All @@ -52,3 +56,7 @@ filter = function(request, response, chain) {
}; };


exports.filter = filter; exports.filter = filter;

You must export a function called "filter", but the module can do any thing else as well.


0 comments on commit e5b2d99

Please sign in to comment.