By default, Streamlined middleware handlers will continue to the next
middleware, while Streamlined route and error handlers won't.
This is generally what you want, but you can specify whether next is
called by explicitly returning true or false.
// middleware to blacklist banned IP addresses,// but allow all other requests to pass through:app.use(function (req, res, _) { var isBanned = db.bannedIPs.search(req.ips, _).length > 0; if (isBanned) { res.send(403); return false; // end the response }});
This module also supports Streamline's smart
global context.
If present, the context is reset for every request, so data can safely be
added to it without affecting other requests.
var globals = require('streamline/lib/globals');// middleware to set a global `locale` variable on every request,// for lower-level modules to use:app.use(function (req, res, __) { // parse locale... then: globals.context.locale = locale;});
Seth Yuan's
streamline-express for the
inspiration and motivation.
streamline-express has supported Express 3 for longer than this module, and
it currently also supports more advanced Express 3 features (like passing
multiple Streamlined handlers to the same app.verb call).
I believe this module has a cleaner API and more robust implementation,
however, but I'm biased. =) Both modules get the job done just fine!