The net/http package contains the ServeMux struct, which implements the Handler interface to be used in a Server struct, but also contains the mechanism of how to define the handling of different paths. The ServeMux pointer contains the methods HandleFunc and Handle, which accept the path, and the HandlerFunc function handles the request for the given path, or another handler does the same.
See the preceding example for how these could be used. The Handler interface and HandlerFunc require implementing the function with request and response arguments. This way you get access to these two structures. The request itself gives access to Headers, the HTTP method, and other request parameters.