Return 403 with PUT verb if lifecycle is not enabled

Signed-off-by: Sven Nebel <nebel.sven@gmail.com>
This commit is contained in:
Sven Nebel 2019-09-25 10:48:36 +01:00
parent c6928b5c6e
commit d186d85649
1 changed files with 6 additions and 6 deletions

View File

@ -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)