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 ...

Get Security with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.