github.com/gravitational/moby@v1.13.1/api/server/middleware.go (about)

     1  package server
     2  
     3  import (
     4  	"github.com/Sirupsen/logrus"
     5  	"github.com/docker/docker/api/server/httputils"
     6  	"github.com/docker/docker/api/server/middleware"
     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 s.cfg.Logging && logrus.GetLevel() == logrus.DebugLevel {
    20  		next = middleware.DebugRequestMiddleware(next)
    21  	}
    22  
    23  	return next
    24  }