From 450d0fc97964a13b42bf39e6cf0dc68ce8f736b7 Mon Sep 17 00:00:00 2001 From: Sketch <75850871+SketchMaster2001@users.noreply.github.com> Date: Wed, 13 Dec 2023 13:46:39 -0500 Subject: [PATCH] Correct MIMEType as well as handle no gamename --- api/groups.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/api/groups.go b/api/groups.go index 477f777..17c01cf 100644 --- a/api/groups.go +++ b/api/groups.go @@ -9,6 +9,8 @@ import ( ) func HandleGroups(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") + u, err := url.Parse(r.URL.String()) if err != nil { panic(err) @@ -19,7 +21,8 @@ func HandleGroups(w http.ResponseWriter, r *http.Request) { panic(err) } - groups := qr2.GetGroups(append(query["gamename"], "")[0]) + gameName := query.Get("gamename") + groups := qr2.GetGroups(gameName) for _, group := range groups { for i, player := range group.Players { @@ -42,7 +45,6 @@ func HandleGroups(w http.ResponseWriter, r *http.Request) { panic(err) } - w.Header().Set("Content-Type", "text/json") w.Header().Set("Content-Length", strconv.Itoa(len(jsonData))) w.Write(jsonData) }