How to handle routes
When a request is made to the server, which matches a route definition, the associated callback functions kick in to process the request and send back a response. These callback functions are responsible for the dynamic behavior of the app; without them routes would simply be dumb interfaces that do nothing at all.
So far, we have been dealing with a single callback function for a route, but a route can have more than one callback function.
As mentioned earlier, the Express routing system is also built around the middleware concept—each route handler has the capability to send a response or pass on the request to the next route-handling middleware in the current or the next matching route.
All of a sudden route handling sounds a little more complicated than what we assumed earlier, doesn't it? Let's find out if it is so.
By now, we are all familiar with how a route definition looks like:
app.get('/', function(req, res) { res.send('welcome'); });
We have been using a single...