create a router using the Gorilla mux
package. This is accomplished via the following code:
r := mux.NewRouter()
eventsrouter := r.PathPrefix("/events").Subrouter()
The preceding code makes use of the router object we created earlier, then calls the PathPrefix
method, which is used to capture any URL path that starts with /events
. Then, finally, we call the Subrouter()
method, which will create a new router object for us to use from now on to handle any incoming requests to URLs that start with /events
. The new router is called eventsrouter
.