mirror of https://github.com/caddyserver/caddy.git
admin: Remove /unload endpoint (is same as DELETE /config/)
This commit is contained in:
parent
cb25dd72ab
commit
7129f6c1c0
28
admin.go
28
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
|
||||
|
|
Loading…
Reference in New Issue