mirror of
https://github.com/gravitl/netmaker.git
synced 2025-12-24 13:28:22 +08:00
v1.2.0: add auth to server shutdown api (#3776)
This commit is contained in:
@@ -35,14 +35,14 @@ func serverHandlers(r *mux.Router) {
|
||||
},
|
||||
).Methods(http.MethodGet)
|
||||
r.HandleFunc(
|
||||
"/api/server/shutdown",
|
||||
func(w http.ResponseWriter, _ *http.Request) {
|
||||
msg := "received api call to shutdown server, sending interruption..."
|
||||
slog.Warn(msg)
|
||||
_, _ = w.Write([]byte(msg))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_ = syscall.Kill(syscall.Getpid(), syscall.SIGINT)
|
||||
},
|
||||
"/api/server/shutdown", logic.SecurityCheck(true,
|
||||
http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
|
||||
msg := "received api call to shutdown server, sending interruption..."
|
||||
slog.Warn(msg)
|
||||
_, _ = w.Write([]byte(msg))
|
||||
w.WriteHeader(http.StatusOK)
|
||||
_ = syscall.Kill(syscall.Getpid(), syscall.SIGINT)
|
||||
})),
|
||||
).Methods(http.MethodPost)
|
||||
r.HandleFunc("/api/server/getconfig", allowUsers(http.HandlerFunc(getConfig))).
|
||||
Methods(http.MethodGet)
|
||||
|
||||
Reference in New Issue
Block a user