From 0188c04655710a9e38ead02ea3e2b529134fc122 Mon Sep 17 00:00:00 2001 From: Matt Huntington Date: Tue, 23 Aug 2016 09:09:20 -0400 Subject: [PATCH] middleware with base url --- server.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/server.js b/server.js index 3eca22e..ef7626b 100644 --- a/server.js +++ b/server.js @@ -13,7 +13,7 @@ app.use(function(req, res, next){ next(); }); -app.use(function(req, res, next){ +app.use('/foo', function(req, res, next){ console.log('3rd middleware doin. stuff'); next(); }); @@ -26,7 +26,11 @@ app.get('/', function(request, response){ app.get('/foo', function(req, res){ res.send('works'); -}) +}); + +app.get('/foo/bar', function(req, res){ + res.send('works'); +}); //params: port, callback to execute once listening has begun app.listen(PORT, function () { //start app listening on port 3000