summaryrefslogtreecommitdiff
path: root/admin.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:53:14 -0700
committerMatthew Holt <mholt@users.noreply.github.com>2019-11-04 12:53:14 -0700
commit7129f6c1c00103a403717a68a0d91965b818db5b (patch)
tree46b426f2319e65f1167b734c62d571a80c85ddd7 /admin.go
parentcb25dd72abec854b359ca8194cb07b2571d950d4 (diff)
admin: Remove /unload endpoint (is same as DELETE /config/)
Diffstat (limited to 'admin.go')
-rw-r--r--admin.go28
1 files changed, 15 insertions, 13 deletions
diff --git a/admin.go b/admin.go
index fb7b34b..502a968 100644
--- a/admin.go
+++ b/admin.go
@@ -90,7 +90,6 @@ func (admin AdminConfig) newAdminHandler(listenAddr string) adminHandler {
addRoute("/load", AdminHandlerFunc(handleLoad))
addRoute("/"+rawConfigKey+"/", AdminHandlerFunc(handleConfig))
addRoute("/id/", AdminHandlerFunc(handleConfigID))
- addRoute("/unload", AdminHandlerFunc(handleUnload))
addRoute("/stop", AdminHandlerFunc(handleStop))
// register debugging endpoints
@@ -543,6 +542,21 @@ func handleConfigID(w http.ResponseWriter, r *http.Request) error {
return ErrInternalRedir
}
+func handleStop(w http.ResponseWriter, r *http.Request) error {
+ defer func() {
+ Log().Named("admin.api").Info("stopping now, bye!! 👋")
+ os.Exit(0)
+ }()
+ err := handleUnload(w, r)
+ if err != nil {
+ Log().Named("admin.api").Error("unload error", zap.Error(err))
+ }
+ return nil
+}
+
+// handleUnload stops the current configuration that is running.
+// Note that doing this can also be accomplished with DELETE /config/
+// but we leave this function because handleStop uses it.
func handleUnload(w http.ResponseWriter, r *http.Request) error {
if r.Method != http.MethodPost {
return APIError{
@@ -566,18 +580,6 @@ func handleUnload(w http.ResponseWriter, r *http.Request) error {
return nil
}
-func handleStop(w http.ResponseWriter, r *http.Request) error {
- defer func() {
- Log().Named("admin.api").Info("stopping now, bye!! 👋")
- os.Exit(0)
- }()
- err := handleUnload(w, r)
- if err != nil {
- Log().Named("admin.api").Error("unload error", zap.Error(err))
- }
- return nil
-}
-
// unsyncedConfigAccess traverses into the current config and performs
// the operation at path according to method, using body and out as
// needed. This is a low-level, unsynchronized function; most callers