Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
admin: Remove /unload endpoint (is same as DELETE /config/)
Matthew Holt committed
Nov 4, 2019 at 12:53 UTC
7129f6c1c00103a403717a68a0d91965b818db5b
1 file changed
+15
-13
admin.go
+15
-13
@@ -90,7 +90,6 @@ func (admin AdminConfig) newAdminHandler(listenAddr string) adminHandler {
90
addRoute("/load", AdminHandlerFunc(handleLoad))
91
addRoute("/"+rawConfigKey+"/", AdminHandlerFunc(handleConfig))
92
addRoute("/id/", AdminHandlerFunc(handleConfigID))
93
- addRoute("/unload", AdminHandlerFunc(handleUnload))
93
addRoute("/stop", AdminHandlerFunc(handleStop))
94
95
// register debugging endpoints
@@ -543,6 +542,21 @@ func handleConfigID(w http.ResponseWriter, r *http.Request) error {
542
return ErrInternalRedir
543
}
544
545
+func handleStop(w http.ResponseWriter, r *http.Request) error {
546
+ defer func() {
547
+ Log().Named("admin.api").Info("stopping now, bye!! 👋")
548
+ os.Exit(0)
549
+ }()
550
+ err := handleUnload(w, r)
551
+ if err != nil {
552
+ Log().Named("admin.api").Error("unload error", zap.Error(err))
553
+ }
554
+ return nil
555
+}
556
+
557
+// handleUnload stops the current configuration that is running.
558
+// Note that doing this can also be accomplished with DELETE /config/
559
+// but we leave this function because handleStop uses it.
560
func handleUnload(w http.ResponseWriter, r *http.Request) error {
561
if r.Method != http.MethodPost {
562
return APIError{
@@ -566,18 +580,6 @@ func handleUnload(w http.ResponseWriter, r *http.Request) error {
580
return nil
581
}
582
569
-func handleStop(w http.ResponseWriter, r *http.Request) error {
570
- defer func() {
571
- Log().Named("admin.api").Info("stopping now, bye!! 👋")
572
- os.Exit(0)
573
- }()
574
- err := handleUnload(w, r)
575
- if err != nil {
576
- Log().Named("admin.api").Error("unload error", zap.Error(err))
577
- }
578
- return nil
579
-}
580
-
583
// unsyncedConfigAccess traverses into the current config and performs
584
// the operation at path according to method, using body and out as
585
// needed. This is a low-level, unsynchronized function; most callers