From 5e551b4eafb5a5d51153b34bd0e55eb49b4675fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Z=C3=BCrcher?= Date: Sat, 31 Jan 2026 20:14:54 +0100 Subject: [PATCH] add content-type header and error response --- handlers/infos.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/handlers/infos.go b/handlers/infos.go index a26b72d..4062ebb 100644 --- a/handlers/infos.go +++ b/handlers/infos.go @@ -34,6 +34,7 @@ func getActiveIP() string { } func InfoHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "application/json") port := env.Port.GetValue() if port == "" { port = "8080" @@ -49,5 +50,9 @@ func InfoHandler(w http.ResponseWriter, r *http.Request) { "port": port, "speed": GetInterval(), } - json.NewEncoder(w).Encode(data) + err := json.NewEncoder(w).Encode(data) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } }