Merge pull request #6057 from snebel29/fix/management-api-return-code-when-disabled

Fix management api return code when lifecycle API is disabled
This commit is contained in:
Björn Rabenstein 2019-09-30 11:43:28 +02:00 committed by GitHub
commit ea2c836e1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 7 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"))
})
w.Write([]byte("Lifecycle API is 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)