all respond methods • Can be build iteratively (CORS, HTTP Code) • Can terminate a Request ◦ .render(), .send(), .end() ◦ No ‘next()’ invocation is required
arity • If omitted the middleware is Synchronous • If truthy value is passed fails the request ◦ next(‘no go’); • Invoke once -and only once- to go to next • If middleware is Terminal do not include it (i.e. final controller call that renders)
'/public')); app.use(logger()); app.use(function(req, res){ res.send('Hello'); }); app.get(‘/’, function(req, res){ res.send('World'); }); Sequence MATTERS Static assets will get served without generating a Log
next) { if (!req.user) { res.status(401).send(‘No go dude’); return; // .send() is a terminal action // no need to call next }); next(); // Client is authed, go on... }); Leveraging Augmentation