0
0
Fork 0
mirror of https://github.com/matrix-org/dendrite synced 2024-06-06 14:38:56 +02:00

Fix #3354 [skip ci]

This commit is contained in:
Till Faelligen 2024-04-07 19:40:30 +02:00
parent b732eede27
commit ea61030d82
No known key found for this signature in database
GPG key ID: 3DF82D8AB9211D4E
2 changed files with 4 additions and 4 deletions

View file

@ -66,15 +66,15 @@ func NewRouters() Routers {
}
var NotAllowedHandler = WrapHandlerInCORS(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusMethodNotAllowed)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusMethodNotAllowed)
unrecognizedErr, _ := json.Marshal(spec.Unrecognized("Unrecognized request")) // nolint:misspell
_, _ = w.Write(unrecognizedErr) // nolint:misspell
}))
var NotFoundCORSHandler = WrapHandlerInCORS(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusNotFound)
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusNotFound)
unrecognizedErr, _ := json.Marshal(spec.Unrecognized("Unrecognized request")) // nolint:misspell
_, _ = w.Write(unrecognizedErr) // nolint:misspell
}))

View file

@ -17,7 +17,7 @@ func TestRoutersError(t *testing.T) {
if rec.Code != http.StatusNotFound {
t.Fatalf("unexpected status code: %d - %s", rec.Code, rec.Body.String())
}
if ct := rec.Header().Get("Content-Type"); ct != "application/json" {
if ct := rec.Result().Header.Get("Content-Type"); ct != "application/json" {
t.Fatalf("unexpected content-type: %s", ct)
}
@ -32,7 +32,7 @@ func TestRoutersError(t *testing.T) {
if rec.Code != http.StatusMethodNotAllowed {
t.Fatalf("unexpected status code: %d - %s", rec.Code, rec.Body.String())
}
if ct := rec.Header().Get("Content-Type"); ct != "application/json" {
if ct := rec.Result().Header.Get("Content-Type"); ct != "application/json" {
t.Fatalf("unexpected content-type: %s", ct)
}
}