From c82e3a5ff8071338f6ef446da0380a2692552ccb Mon Sep 17 00:00:00 2001 From: Andrew Marcuse Date: Fri, 27 Nov 2020 22:33:53 -0500 Subject: [PATCH] FIX: json response for specific field endpoints --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index d9e86fa..a43562c 100644 --- a/main.go +++ b/main.go @@ -154,7 +154,11 @@ func mainHandler(c *gin.Context) { c.String(404, "Not Found") return } - c.String(200, fmt.Sprintln(fieldResult)) + if wantsJSON { + c.JSON(200, fieldResult) + } else { + c.String(200, fmt.Sprintln(fieldResult)) + } }