From 72508dfb23f3aece1a30303821282524f67e581d Mon Sep 17 00:00:00 2001 From: Lars Kiesow Date: Thu, 1 Feb 2024 00:15:33 +0100 Subject: [PATCH] Simplify JSON Result Instead of manually generating JSON, Gin can automatically generate JSON results. This is easier and will also generate correct content type headers. --- main.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/main.go b/main.go index 8604447..3075730 100644 --- a/main.go +++ b/main.go @@ -110,8 +110,7 @@ func setupRouter() *gin.Engine { var result AgentStateResult json.Unmarshal([]byte(s), &result) - capturing, _ := json.Marshal(result.Update.State == "capturing") - c.String(http.StatusOK, string(capturing)) + c.JSON(http.StatusOK, result.Update.State == "capturing") }) return r @@ -123,6 +122,5 @@ func main() { return } r := setupRouter() - // Listen and Server in 0.0.0.0:8080 r.Run(config.Listen) }