Package hnyhttprouter has Middleware to use with the httprouter muxer.
hnyhttprouter has Middleware to wrap individual handlers, and is best used in conjunction with the nethttp WrapHandler function. Using these two together will get you an event for every request that comes through your application while also decorating the most interesting paths (the handlers that you wrap) with additional fields from the httprouter patterns.
Middleware wraps httprouter handlers. Since it wraps handlers with explicit parameters, it can add those values to the event it generates.
// assume you have handlers named hello and index var hello func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) var index func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) router := httprouter.New() // call regular httprouter Handles with wrappers to extract parameters router.GET("/hello/:name", Middleware(hello)) // though the wrapper also works on routes that don't have parameters router.GET("/", Middleware(index)) // wrap the main router to set everything up for instrumenting log.Fatal(http.ListenAndServe(":8080", hnynethttp.WrapHandler(router)))