(c *gin.Context, code int, obj interface{})
| 33 | } |
| 34 | |
| 35 | func GinRenderJSON(c *gin.Context, code int, obj interface{}) { |
| 36 | if requestsPrettyRendering(c) { |
| 37 | c.IndentedJSON(code, obj) |
| 38 | } else { |
| 39 | c.JSON(code, obj) |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | func requestsPrettyRendering(c *gin.Context) bool { |
| 44 | if p, ok := c.GetQuery("pretty"); ok && (strings.EqualFold(p, "true") || strings.EqualFold(p, "")) { |