2015-09-15 23:01:49 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/Sirupsen/logrus"
|
2015-09-23 23:42:08 +00:00
|
|
|
"github.com/docker/docker/api/server/httputils"
|
2016-02-24 18:17:43 +00:00
|
|
|
"github.com/docker/docker/api/server/middleware"
|
2015-09-15 23:01:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// handleWithGlobalMiddlwares wraps the handler function for a request with
|
|
|
|
// the server's global middlewares. The order of the middlewares is backwards,
|
2015-12-13 16:00:39 +00:00
|
|
|
// meaning that the first in the list will be evaluated last.
|
2015-09-23 23:42:08 +00:00
|
|
|
func (s *Server) handleWithGlobalMiddlewares(handler httputils.APIFunc) httputils.APIFunc {
|
2016-02-24 18:17:43 +00:00
|
|
|
next := handler
|
|
|
|
|
2016-04-08 23:22:39 +00:00
|
|
|
for _, m := range s.middlewares {
|
|
|
|
next = m.WrapHandler(next)
|
2015-09-15 23:01:49 +00:00
|
|
|
}
|
|
|
|
|
2015-12-01 19:33:33 +00:00
|
|
|
if s.cfg.Logging && logrus.GetLevel() == logrus.DebugLevel {
|
2016-02-24 18:17:43 +00:00
|
|
|
next = middleware.DebugRequestMiddleware(next)
|
2015-10-22 14:55:23 +00:00
|
|
|
}
|
|
|
|
|
2016-02-24 18:17:43 +00:00
|
|
|
return next
|
2015-09-15 23:01:49 +00:00
|
|
|
}
|