From 1fa54af69ec887f73be24a17dbdcdca90479411b Mon Sep 17 00:00:00 2001 From: Ali Nehzat Date: Thu, 29 Jun 2023 19:16:20 +1000 Subject: [PATCH] add utf-8 charset to application/json responses --- cmd/happy/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/happy/main.go b/cmd/happy/main.go index afa9606..70606ac 100644 --- a/cmd/happy/main.go +++ b/cmd/happy/main.go @@ -229,7 +229,7 @@ func generateHandler(gctx *genContext, eps []endpoint, tree *tree) error { w.L(" http.Error(w, `failed to encode response: ` + err.Error(), http.StatusInternalServerError)") w.L(" return") w.L("}") - w.L("w.Header().Set(\"Content-Type\", \"application/json\")") + w.L("w.Header().Set(\"Content-Type\", \"application/json; charset=utf-8\")") w.L("w.Header().Set(\"Content-Length\", strconv.Itoa(len(data)))") w.L("w.WriteHeader(http.StatusOK)") w.L("w.Write(data)")