I want to be able to send different requests through different middleware stacks.
I think I need two app s expressions, and some kind of branching. eg:.
var app = express(); var alt_app = express(); app.use(logger('dev')); app.use(bodyParser.json()); app.use(function(req, res, next) { if (some_condition(req)) { divert_request_to_alt_app(); } else { next(); } } app.use(middleware_that_must_not_affect_alt_app()); alt_app.use(middleware_that_only_affects_alt_app());
Is such a strategy possible?
If so, what should divert_request_to_alt_app() be?
If not, what other approaches?
source share