An exciting proposal is expected to land in Go 1.22 - enhancing the pattern-matching capabilities of the default HTTP serving multiplexer in the net/http package.

The existing multiplexer (http.ServeMux) offers rudimentary path matching, but not much beyond that. This led to a cottage industry of 3rd party libraries to implement more powerful capabilities. I've explored these options in my REST Servers in Go series, in parts 1 and 2.

The new multiplexer in 1.22 is going to significantly bridge the gap from 3rd party packages by providing advanced matching. In this short post I'll provide a quick introduction to the new multiplexer (mux). I'll also revisit the example from the REST Servers in Go series and compare how the new stdlib mux fares against gorilla/mux.

continue reading on eli.thegreenplace.net

⚠️ This post links to an external website. ⚠️