Skip to content

Instantly share code, notes, and snippets.

@flovilmart
Created April 23, 2017 00:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save flovilmart/6e72ae9a5c61246d21a7465013e64d75 to your computer and use it in GitHub Desktop.
Save flovilmart/6e72ae9a5c61246d21a7465013e64d75 to your computer and use it in GitHub Desktop.
$ curl http://localhost:8080/app1
# logs
# main middleware
# app1 middleware
$ curl http://localhost:8080/app2
# logs
# main middleware
# app2 middleware
var express = require('express');
var app1 = express();
var app2 = express();
var app = express();
app.use(function(req, res, next) {
console.log('main middleware');
next();
});
app1.use(function(req, res, next) {
console.log('app1 middleware');
next();
});
app1.get('/', (req, res) => {
res.sendStatus(200);
});
app2.use(function(req, res, next) {
console.log('app2 middleware');
next();
});
app2.get('/', (req, res) => {
res.sendStatus(200);
});
app.use('/app1', app1);
app.use('/app2', app2);
app.listen(8080);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment