diff options
author | Valery Piashchynski <[email protected]> | 2021-05-13 17:15:00 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-05-13 17:15:00 +0300 |
commit | 2be94ad0400e2f523d87f47e09a7bf505edef689 (patch) | |
tree | 1824c8ee28d0c6ce2884b99d0a4eaa99dcaa9cbb /plugins/http/serve.go | |
parent | 705b69631dc91323c64a19594dcfeca06ea4fa5a (diff) |
- Remove unsafe casting (replace with a less unsafe)
- Make the static plugin great again (separate plugin)
- Revert new behavior
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/http/serve.go')
-rw-r--r-- | plugins/http/serve.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/http/serve.go b/plugins/http/serve.go index 338d4339..9bb11e35 100644 --- a/plugins/http/serve.go +++ b/plugins/http/serve.go @@ -233,10 +233,19 @@ func (s *Plugin) tlsAddr(host string, forcePort bool) string { func applyMiddlewares(server *http.Server, middlewares map[string]Middleware, order []string, log logger.Logger) { for i := len(order) - 1; i >= 0; i-- { + // set static last in the row + if order[i] == "static" { + continue + } if mdwr, ok := middlewares[order[i]]; ok { server.Handler = mdwr.Middleware(server.Handler) } else { log.Warn("requested middleware does not exist", "requested", order[i]) } } + + // set static if exists + if mdwr, ok := middlewares["static"]; ok { + server.Handler = mdwr.Middleware(server.Handler) + } } |