Permalink
Browse files

Added read me for my two commits.

  • Loading branch information...
1 parent d32ab20 commit b87f18e203dc0a9071d2cf7b8eb06b02dd2f877b @mckk mckk committed Aug 6, 2011
Showing with 15 additions and 2 deletions.
  1. +15 −2 README.markdown
View
@@ -29,11 +29,11 @@ edit_p = function(req,res){
routes = {
get:{
- '/': [home],
+ '/': home,
'/edit': [requireLogin,edit]
},
post:{
- '/edit' : [edit_p]
+ '/edit' : edit_p
}
}
</pre>
@@ -49,4 +49,17 @@ where 'app' is the express app instance.
The middleware you provide in the list for each page, are evaluated from left to right.
Hence, anything but the last function needs to have a 'next' function in the parameter to continue the execution.
+If you're not using any middleware you don't have to put the final function in an array.
+
+If you want to apply a piece (or multiple pieces) of middleware to all of your routing functions just do:
+
+<pre>
+arouter = require('./arouter')
+arouter.router(routes,app, Middleware1)
+</pre>
+
+<pre>
+arouter = require('./arouter')
+arouter.router(routes,app, [Middleware1, Middleware2])
+</pre>

0 comments on commit b87f18e

Please sign in to comment.