3 ms·
The first thing people tend to do is to replace the default, very primitive "mux" with a router that more closely aligns with modern expectations, such as httpr
by lobster_johnson 10y ago
The first thing people tend to do is to replace the default, very primitive "mux" with a router that more closely aligns with modern expectations, such as httprouter (https://github.com/julienschmidt/httprouter https://github.com/julienschmidt/httprouter) or chi (https://github.com/pressly/chi https://github.com/pressly/chi).
These libraries also support middleware wrapping [1], a technique that the default mux supports but doesn't help you with. For example, adding CORS headers or logging the request.
[1] https://justinas.org/writing-http-middleware-in-go/ https://justinas.org/writing-http-middleware-in-go/