From d186d856493c3e75f4c5ec3beea461c1419d1895 Mon Sep 17 00:00:00 2001 From: Sven Nebel Date: Wed, 25 Sep 2019 10:48:36 +0100 Subject: [PATCH] Return 403 with PUT verb if lifecycle is not enabled Signed-off-by: Sven Nebel --- web/web.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/web/web.go b/web/web.go index 6d956a7dc..0b9f4dc5a 100644 --- a/web/web.go +++ b/web/web.go @@ -344,14 +344,14 @@ func New(logger log.Logger, o *Options) *Handler { router.Post("/-/reload", h.reload) router.Put("/-/reload", h.reload) } else { - router.Post("/-/quit", func(w http.ResponseWriter, _ *http.Request) { + forbiddenAPINotEnabled := func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusForbidden) w.Write([]byte("Lifecycle APIs are not enabled")) - }) - router.Post("/-/reload", func(w http.ResponseWriter, _ *http.Request) { - w.WriteHeader(http.StatusForbidden) - w.Write([]byte("Lifecycle APIs are not enabled")) - }) + } + router.Post("/-/quit", forbiddenAPINotEnabled) + router.Put("/-/quit", forbiddenAPINotEnabled) + router.Post("/-/reload", forbiddenAPINotEnabled) + router.Put("/-/reload", forbiddenAPINotEnabled) } router.Get("/-/quit", func(w http.ResponseWriter, _ *http.Request) { w.WriteHeader(http.StatusMethodNotAllowed)