-
-
Save flovilmart/6e72ae9a5c61246d21a7465013e64d75 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ curl http://localhost:8080/app1 | |
# logs | |
# main middleware | |
# app1 middleware | |
$ curl http://localhost:8080/app2 | |
# logs | |
# main middleware | |
# app2 middleware |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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