add content-type header and error response
All checks were successful
Build Slideshow App / build (amd64, , linux) (push) Successful in 1m37s
Build Slideshow App / build (amd64, .exe, windows) (push) Successful in 1m19s
Build Slideshow App / build (arm, 7, , linux) (push) Successful in 1m27s
Build Slideshow App / build (arm64, , linux) (push) Successful in 1m28s

This commit is contained in:
Adrian Zürcher
2026-01-31 20:14:54 +01:00
parent 7aef03a7cd
commit 5e551b4eaf

View File

@@ -34,6 +34,7 @@ func getActiveIP() string {
} }
func InfoHandler(w http.ResponseWriter, r *http.Request) { func InfoHandler(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
port := env.Port.GetValue() port := env.Port.GetValue()
if port == "" { if port == "" {
port = "8080" port = "8080"
@@ -49,5 +50,9 @@ func InfoHandler(w http.ResponseWriter, r *http.Request) {
"port": port, "port": port,
"speed": GetInterval(), "speed": GetInterval(),
} }
json.NewEncoder(w).Encode(data) err := json.NewEncoder(w).Encode(data)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
} }