From 6816df315878ba0887e2dfa42ff62ffc4dfd2889 Mon Sep 17 00:00:00 2001 From: maru Date: Sat, 20 Apr 2024 16:58:04 -0400 Subject: [PATCH] Set content type of JSON responses --- api/endpoints.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/api/endpoints.go b/api/endpoints.go index e4819b9..58ab6bd 100644 --- a/api/endpoints.go +++ b/api/endpoints.go @@ -68,6 +68,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { httpError(w, r, fmt.Errorf("failed to encode response json: %s", err), http.StatusInternalServerError) return } + + w.Header().Set("Content-Type", "application/json") case "/account/register": err := r.ParseForm() if err != nil { @@ -100,6 +102,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { httpError(w, r, fmt.Errorf("failed to encode response json: %s", err), http.StatusInternalServerError) return } + + w.Header().Set("Content-Type", "application/json") case "/account/logout": token, err := base64.StdEncoding.DecodeString(r.Header.Get("Authorization")) if err != nil { @@ -127,6 +131,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { httpError(w, r, fmt.Errorf("failed to encode response json: %s", err), http.StatusInternalServerError) return } + + w.Header().Set("Content-Type", "application/json") case "/game/classicsessioncount": w.Write([]byte(strconv.Itoa(classicSessionCount))) @@ -214,6 +220,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + w.Header().Set("Content-Type", "application/json") + // /daily case "/daily/seed": w.Write([]byte(daily.Seed())) @@ -249,6 +257,8 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { httpError(w, r, fmt.Errorf("failed to encode response json: %s", err), http.StatusInternalServerError) return } + + w.Header().Set("Content-Type", "application/json") case "/daily/rankingpagecount": var category int if r.URL.Query().Has("category") {