diff options
author | devonh <devon.dmytro@gmail.com> | 2023-05-17 00:33:27 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-17 00:33:27 +0000 |
commit | 67d68768574a234b733eb3e4061644fc098a69f6 (patch) | |
tree | 819e9a0a150b68181d91112ffc7e0d6030412b77 /internal/httputil | |
parent | 0489d16f95a3d9f1f5bc532e2060bd2482d7b156 (diff) |
Move MakeJoin logic to GMSL (#3081)
Diffstat (limited to 'internal/httputil')
-rw-r--r-- | internal/httputil/routing.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/internal/httputil/routing.go b/internal/httputil/routing.go index c733c8ce..2052c798 100644 --- a/internal/httputil/routing.go +++ b/internal/httputil/routing.go @@ -15,10 +15,12 @@ package httputil import ( + "encoding/json" "net/http" "net/url" "github.com/gorilla/mux" + "github.com/matrix-org/gomatrixserverlib/spec" ) // URLDecodeMapValues is a function that iterates through each of the items in a @@ -66,13 +68,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.Write([]byte(`{"errcode":"M_UNRECOGNIZED","error":"Unrecognized request"}`)) // nolint:misspell + 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.Write([]byte(`{"errcode":"M_UNRECOGNIZED","error":"Unrecognized request"}`)) // nolint:misspell + unrecognizedErr, _ := json.Marshal(spec.Unrecognized("Unrecognized request")) // nolint:misspell + _, _ = w.Write(unrecognizedErr) // nolint:misspell })) func (r *Routers) configureHTTPErrors() { |