Understanding HTTP Server in Go #6 - Mux
Up until now, we’ve been using the DefaultServeMux, but it’s time to wield more control and precision by explicitly using the http.ServeMux. Plus, we’ll look at the powerful frameworks available, like Gorilla Mux and Echo, that take web server functionality to new heights. Check out previous posts: Part 1: https://surajincloud.com/understanding-http-server-in-go-basic Part 2: https://surajincloud.com/understanding-http-server-in-go-using-httpserver-struct Part 3: https://surajincloud.com/understanding-http-server-in-go-handlers Part 4: https://surajincloud.com/understanding-http-server-in-go-multiple-handlers Part 5: https://surajincloud.com/understanding-http-server-in-go-handlefunc Why do we need this? While the DefaultServeMux In Golang does a great job of handling basic routing, there will come a point where you’ll want more control over your application’s routes. This is where the http.ServeMux steps in. It empowers you to explicitly define how your application responds to different routes, giving you fine-grained control over your server’s behaviour. ...