Middleware with Negroni
Middleware is the term for functions that can be tied to the request/response flow and take action or make modification before passing it on to the next middleware and ultimately back to the client.
Middleware is a series of functions run in order on each request. You can add more functions to this chain. We will take a look at some practical examples, such as blacklisting IP addresses, adding logging, and adding authorization checks.
The order of middleware is important. For example, we may want to put the logging middleware first, and then the IP blacklisting middleware. We would want the IP blacklist module to run first, or at least near the beginning, so that other middlewares don't waste resources processing a ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access