Using Middleware Functions
Learn about middleware functions and how to use them in a Deno application.
We'll cover the following...
If you’ve used any HTTP framework, be it JavaScript or otherwise, you’re probably familiar with middleware functions. If not, no worries—that’s what we’ll explain in this section.
Let’s start with a definition borrowed from the Express.js documentation:
“Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. The next middleware function is commonly denoted by a variable named next.”
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 lifecycle (answering requests or skipping other