Fix config tab showing byte string instead of text #479

This commit is contained in:
Alexey Khit
2023-06-29 16:16:08 +03:00
parent 74cef13479
commit 9de980a63c
+9 -1
View File
@@ -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"