github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/api/server/middleware.go (about) 1 package server // import "github.com/Prakhar-Agarwal-byte/moby/api/server" 2 3 import ( 4 "github.com/Prakhar-Agarwal-byte/moby/api/server/httputils" 5 "github.com/Prakhar-Agarwal-byte/moby/api/server/middleware" 6 "github.com/containerd/log" 7 ) 8 9 // handlerWithGlobalMiddlewares wraps the handler function for a request with 10 // the server's global middlewares. The order of the middlewares is backwards, 11 // meaning that the first in the list will be evaluated last. 12 func (s *Server) handlerWithGlobalMiddlewares(handler httputils.APIFunc) httputils.APIFunc { 13 next := handler 14 15 for _, m := range s.middlewares { 16 next = m.WrapHandler(next) 17 } 18 19 if log.GetLevel() == log.DebugLevel { 20 next = middleware.DebugRequestMiddleware(next) 21 } 22 23 return next 24 }