1
Fork 0

Implement methodNotAllowed.

This commit is contained in:
Juliusz Chroboczek 2024-04-10 14:39:52 +02:00
parent fc6387bb38
commit f646191e01
1 changed files with 13 additions and 1 deletions

View File

@ -145,6 +145,18 @@ func httpError(w http.ResponseWriter, err error) {
http.StatusInternalServerError)
}
func methodNotAllowed(w http.ResponseWriter, methods ...string) {
ms := ""
for _, m := range methods {
if ms != "" {
ms = ms + ", "
}
ms = ms + m
}
w.Header().Set("Allow", ms)
http.Error(w, "method not allowed", http.StatusMethodNotAllowed)
}
const (
normalCacheControl = "max-age=1800"
veryCachableCacheControl = "max-age=86400"
@ -615,7 +627,7 @@ func recordingsHandler(w http.ResponseWriter, r *http.Request) {
func handleGroupAction(w http.ResponseWriter, r *http.Request, group string) {
if r.Method != "POST" {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
methodNotAllowed(w, "POST")
return
}