From b1df41ef17dfe272b2ddf65671b90305cfe6d253 Mon Sep 17 00:00:00 2001 From: sneak Date: Wed, 30 Sep 2020 01:30:21 -0700 Subject: [PATCH] add some info about the types/signatures in route middlewares --- httpserver/routes.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/httpserver/routes.go b/httpserver/routes.go index 53d0c8a..417d002 100644 --- a/httpserver/routes.go +++ b/httpserver/routes.go @@ -13,10 +13,15 @@ func (s *server) routes() { // if you want to use a general purpose middleware (http.Handler // wrapper) on a specific HandleFunc route, you need to take the - // .ServeHTTP of the http.Handler to get a HandleFunc, viz: + // .ServeHTTP of the http.Handler to get its HandleFunc, viz: s.router.HandleFunc("/login", authMiddleware(s.handleLogin()).ServeHTTP).Methods("GET") s.router.HandleFunc("/.well-known/healthcheck.json", s.handleHealthCheck()).Methods("GET") + // the Gorilla mux .Use() takes a http.Handler wrapper func, like + // most things that deal with "middlewares" like alice et c, and + // will call ServeHTTP on it. These middlewares applied by the mux + // (you can .Use() more than one) will be applied to every request + // into the service. s.router.Use(s.LoggingMiddleware()) }