Tutorial by Topics: middleware

Middleware in Django is a framework that allows code to hook into the response / request processing and alter the input or output of Django.

Middleware are classes, that can be assigned to one or more route, and are used to make actions in the early or final phases of the request cycle. We can think of them as a series of layers an HTTP request has to pass through while it's executed

In Go Middleware can be used to execute code before and after handler function. It uses the power of Single Function Interfaces. Can be introduced at any time without affecting the other middleware. For Ex: Authentication logging can be added in later stages of development without disturbing the existing code.

For some time I've searched for the best way to log requests and response in an ASP.Net Core. I was developing services and one of the requirements was to record request with its response in one record the the database. So many topics out there but none worked for me. it's either for request only, response only or simply didn't work. When I was able to finally do it, and it had evolved during my project to better error handling and logging exceptions so I thought of sharing.

Page 1 of 1