From 9de980a63c4c8fa5137dc7387d92a6ca69ee7587 Mon Sep 17 00:00:00 2001 From: Alexey Khit Date: Thu, 29 Jun 2023 16:16:08 +0300 Subject: [PATCH] Fix config tab showing byte string instead of text #479 --- internal/api/api.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/api/api.go b/internal/api/api.go index 5117036b..12751eba 100644 --- a/internal/api/api.go +++ b/internal/api/api.go @@ -110,7 +110,15 @@ func ResponsePrettyJSON(w http.ResponseWriter, v any) { func Response(w http.ResponseWriter, body any, contentType string) { w.Header().Set("Content-Type", contentType) - _, _ = fmt.Fprint(w, body) + + switch v := body.(type) { + case []byte: + _, _ = w.Write(v) + case string: + _, _ = w.Write([]byte(v)) + default: + _, _ = fmt.Fprint(w, body) + } } const StreamNotFound = "stream not found"