You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
605 B

package api
import "net/http"
func (r *Router) handleClearSystemLogs(w http.ResponseWriter, req *http.Request) {
ctx, ok := r.authorizeCommand(w, req, commandSpec{Action: "log.system.clear", Target: "system", Permission: "log.clear"})
if !ok {
return
}
var body struct {
Confirmation string `json:"confirmation"`
}
if ok, _ := decodeJSONBody(w, req, &body, false); !ok {
return
}
if body.Confirmation != "SYSTEM" {
writeError(w, http.StatusBadRequest, "validation_failed", "confirm SYSTEM exactly")
return
}
result, err := r.store.ClearSystemLogs(ctx)
writeResult(w, result, err)
}