gin-gonic / gin

Gin is a HTTP web framework written in Go (Golang). It features a Martini-like API with much better performance -- up to 40 times faster. If you need smashing performance, get yourself some Gin.
https://gin-gonic.com/
MIT License
77.95k stars 7.97k forks source link

Overwrite `JSONRender` similar to `HTMLRender` #4041

Open tylermmorton opened 2 weeks ago

tylermmorton commented 2 weeks ago

Description

Similar to this issue and this commit I found, where you can overwrite the HTMLRender method to support custom template engines...

It would be useful to overwrite the JSONRender method so the functionality of the JSON marshaller can be customized for all responses written using c.JSON(). The only alternative is to implement json.Marshaler on each struct type, but I have a lot of response types.

Curious to know if this would be a supported effort, I'm happy to look into implementing this

JimChenWYU commented 2 weeks ago

https://github.com/gin-gonic/gin/pull/3391

Maybe you need this feature. But I don't think it will be solved as soon as possible. Because https://github.com/gin-gonic/gin/issues/3766