2018-02-05 16:05:59 -05:00
|
|
|
package server // import "github.com/docker/docker/api/server"
|
2015-09-15 19:01:49 -04:00
|
|
|
|
|
|
|
import (
|
2015-09-23 19:42:08 -04:00
|
|
|
"github.com/docker/docker/api/server/httputils"
|
2016-02-24 13:17:43 -05:00
|
|
|
"github.com/docker/docker/api/server/middleware"
|
2017-07-26 17:42:13 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2015-09-15 19:01:49 -04:00
|
|
|
)
|
|
|
|
|
2016-08-26 06:26:15 -04:00
|
|
|
// handlerWithGlobalMiddlewares wraps the handler function for a request with
|
2015-09-15 19:01:49 -04:00
|
|
|
// the server's global middlewares. The order of the middlewares is backwards,
|
2015-12-13 11:00:39 -05:00
|
|
|
// meaning that the first in the list will be evaluated last.
|
2016-08-11 22:50:22 -04:00
|
|
|
func (s *Server) handlerWithGlobalMiddlewares(handler httputils.APIFunc) httputils.APIFunc {
|
2016-02-24 13:17:43 -05:00
|
|
|
next := handler
|
|
|
|
|
2016-04-08 19:22:39 -04:00
|
|
|
for _, m := range s.middlewares {
|
|
|
|
next = m.WrapHandler(next)
|
2015-09-15 19:01:49 -04:00
|
|
|
}
|
|
|
|
|
2022-04-22 13:19:11 -04:00
|
|
|
if logrus.GetLevel() == logrus.DebugLevel {
|
2016-02-24 13:17:43 -05:00
|
|
|
next = middleware.DebugRequestMiddleware(next)
|
2015-10-22 10:55:23 -04:00
|
|
|
}
|
|
|
|
|
2016-02-24 13:17:43 -05:00
|
|
|
return next
|
2015-09-15 19:01:49 -04:00
|
|
|
}
|