Using middleware functions
If you have used any HTTP framework, be it JavaScript or otherwise, you are probably familiar with the concept of middleware functions. If you are not, then no worries – that's what we'll explain in this section.
Let's start with a definition borrowed from the Express.js documentation (http://expressjs.com/en/guide/writing-middleware.html):
Middleware functions intercept requests and have the ability to act on them. They can be used in many different use cases, as follows:
- Changing the request and response objects
- Ending the request-response life cycle (answering requests or skipping other handlers)
- Calling...