I've noticed that using Gin to return a response like this:
c.JSON(http.StatusOK, jsonData)
automatically creates the following header:
application/json; charset=utf-8
Is it possible to modify the header somehow to just return
application/json
I'd rather take this approach than splitting the string at the ;
Modify the source code to remove the ; charset=utf-8
string, or
Have a wrapper function which manually sets Content-Type
before the gin.Context.JSON
call:
func JSON(c *gin.Context, code int, obj interface{}) {
c.Header("Content-Type", "application/json")
c.JSON(code, obj)
}
// ...
JSON(c, http.StatusOK, jsonData)