2018-02-05 21:05:59 +00:00
|
|
|
package server // import "github.com/docker/docker/api/server"
|
2015-09-15 23:01:49 +00:00
|
|
|
|
|
|
|
import (
|
2023-07-30 15:18:56 +00:00
|
|
|
"github.com/containerd/containerd/log"
|
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
|
|
|
)
|
|
|
|
|
2016-08-26 10:26:15 +00:00
|
|
|
// handlerWithGlobalMiddlewares wraps the handler function for a request with
|
2015-09-15 23:01:49 +00:00
|
|
|
// 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.
|
2016-08-12 02:50:22 +00:00
|
|
|
func (s *Server) handlerWithGlobalMiddlewares(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
|
|
|
}
|
|
|
|
|
2023-07-30 15:18:56 +00:00
|
|
|
if log.GetLevel() == log.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
|
|
|
}
|