admin: set Allow header on /info 405 response

Per RFC 9110 §15.5.6, a 405 response must include an Allow header
listing the supported methods.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Zack Wagner 2026-10-07 09:21:08 -04:00
parent 177f7244a0
commit 5cc146a7b1
No known key found for this signature in database
2 changed files with 4 additions and 0 deletions

View file

@ -57,6 +57,7 @@ type infoResponse struct {
func (AdminInfo) handleInfo(w http.ResponseWriter, r *http.Request) error {
if r.Method != http.MethodGet {
w.Header().Set("Allow", http.MethodGet)
return APIError{
HTTPStatus: http.StatusMethodNotAllowed,
Message: "method not allowed",

View file

@ -90,5 +90,8 @@ func TestAdminInfoHandler(t *testing.T) {
if apiErr.HTTPStatus != http.StatusMethodNotAllowed {
t.Errorf("expected status %d, got %d", http.StatusMethodNotAllowed, apiErr.HTTPStatus)
}
if allow := rec.Header().Get("Allow"); allow != http.MethodGet {
t.Errorf("expected Allow header %q, got %q", http.MethodGet, allow)
}
})
}