⚠️ This post links to an external website. ⚠️
For many years, I've used third-party packages to help organize and manage middleware in my Go web applications. In small projects, I often used alice to create middleware 'chains' that I could reuse across multiple routes. And for larger applications, with lots of middleware and routes, I typically used a router like chi or flow to create nested route 'groups' with per-group middleware.
But since Go 1.22 introduced the new pattern matching functionality for
http.ServeMux, where possible I've tried to drop third-party dependencies from my routing logic and shift to using just the standard library.But going all-in on the standard library leaves a good question: how should we organize and manage middleware without using any third-party packages?
continue reading on www.alexedwards.net
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.