Ordering docs
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Tj Holowaychuk · committed by Tj Holowaychuk · parent 334a18a · Browse files · 1 file·+25 added−25 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
1 file+25 added−25 removed
- other:+25 added−25 removed
Provenance
- Commit
296f127- Tree
212e2e3- Author
Tj Holowaychuk <tj@vision-media.ca>- Committer
Tj Holowaychuk <tj@vision-media.ca>- Parent
334a18a
1 file changed+25 added−25 removed
modified:docs/guide.md+25 added-25 removed
168 unmodified lines169 app.get('/users', function(req, res){170 // do something else171 });172 173+### Middleware174+175+Middleware via [Connect](http://github.com/senchalabs/connect) can be176+passed to _express.createServer()_ as you would with a regular Connect server. For example:177+178+ var express = require('express');179+180+ var app = express.createServer(181+ express.logger(),182+ express.bodyDecoder()183+ );184+185+Alternatively we can _use()_ them which is useful when adding middleware within _configure()_ blocks:186+187+ app.use(express.logger({ format: ':method :uri' }));188+189+Typically with connect middleware you would _require('connect')_ like so:190+191+ var connect = require('connect');192+ app.use(connect.logger());193+194+This is somewhat annoying, so express re-exports these middleware properties, however they are _identical_:195+196+ app.use(express.logger());197+198 ### Route Middleware199 200 Routes may utilize route-specific middleware by passing one or more additional callbacks (or arrays) to the method. This feature is extremely useful for restricting access, loading data used by the route etc.201 105 unmodified lines307 console.log(req.body.user);308 res.redirect('back');309 });310 286-### Middleware287-288-Middleware via [Connect](http://github.com/senchalabs/connect) can be289-passed to _express.createServer()_ as you would with a regular Connect server. For example:290-291- var express = require('express');292-293- var app = express.createServer(294- express.logger(),295- express.bodyDecoder()296- );297-298-Alternatively we can _use()_ them which is useful when adding middleware within _configure()_ blocks:299-300- app.use(express.logger({ format: ':method :uri' }));301-302-Typically with connect middleware you would _require('connect')_ like so:303-304- var connect = require('connect');305- app.use(connect.logger());306-307-This is somewhat annoying, so express re-exports these middleware properties, however they are _identical_:308-309- app.use(express.logger());310-311 ### Error Handling312 313 Express provides the _app.error()_ method which receives exceptions thrown within a route,314 or passed to _next(err)_. Below is an example which serves different pages based on our599 unmodified lines