1
Fork 0
mirror of https://github.com/jech/galene.git synced 2024-11-09 18:25:58 +01:00

Implement methodNotAllowed.

This commit is contained in:
Juliusz Chroboczek 2024-04-10 14:39:52 +02:00
parent fc6387bb38
commit f646191e01

View file

@ -145,6 +145,18 @@ func httpError(w http.ResponseWriter, err error) {
http.StatusInternalServerError) 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 ( const (
normalCacheControl = "max-age=1800" normalCacheControl = "max-age=1800"
veryCachableCacheControl = "max-age=86400" 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) { func handleGroupAction(w http.ResponseWriter, r *http.Request, group string) {
if r.Method != "POST" { if r.Method != "POST" {
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed) methodNotAllowed(w, "POST")
return return
} }