Last active
October 20, 2017 17:50
-
-
Save d4goxn/6941157 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
var express = require( 'express' ); | |
app = express(); | |
app.get( '/', function( req, res ) { | |
console.log( 'app: index' ); | |
res.send( 200 ); | |
}); | |
subApp = express(); | |
subApp.use( function( req, res, next ) { | |
console.log( 'subApp: middleware, called for app\'s routes, called twice for subApp\'s routes' ); | |
next(); | |
}); | |
subApp.use( '/subapp', function( req, res, next ) { | |
console.log( 'subApp: middleware, called once for subApp\'s routes' ); | |
next(); | |
}); | |
subApp.get( '/subapp/page', function( req, res ) { | |
console.log( 'subApp: page' ); | |
res.send( 200 ); | |
}); | |
app.use( subApp ); | |
app.listen( 3000 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment