From 5a94b7a588bd7f59db4ff3c67f18f2323b6cc3fb Mon Sep 17 00:00:00 2001 From: George Shammas Date: Wed, 5 Jan 2022 10:46:52 -0500 Subject: [PATCH] Change format of js response for single object requests --- main.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index 1c4b2e6..9263806 100644 --- a/main.go +++ b/main.go @@ -175,8 +175,8 @@ func mainHandler(c *gin.Context) { c.JSON(200, fieldResult) } else if wantsJS { c.Writer.Header().Set("Content-Type", "application/javascript") - response, _ := json.Marshal(map[string]interface{}{fields[0]: fieldResult}) - c.String(200, "ifconfig_io = %v\n", string(response)) + response, _ := json.Marshal(fieldResult) + c.String(200, "%v = %v\n", fields[0], string(response)) } else { c.String(200, fmt.Sprintln(fieldResult)) }