Merge 84a97ef73e13c71e757aaefddbaf9213e6bc3442 into c3d1092b3b48addf6f9cd00fe274ec3bd14650eb

This commit is contained in:
hooting 2025-10-11 21:19:01 +08:00 committed by GitHub
commit b771dd8af6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -823,6 +823,11 @@ func (c *Context) ShouldBindJSON(obj any) error {
return c.ShouldBindWith(obj, binding.JSON)
}
// ShouldBindMsgPack is a shortcut for c.ShouldBindWith(obj, binding.MsgPack).
func (c *Context) ShouldBindMsgPack(obj interface{}) error {
return c.ShouldBindWith(obj, binding.MsgPack)
}
// ShouldBindXML is a shortcut for c.ShouldBindWith(obj, binding.XML).
func (c *Context) ShouldBindXML(obj any) error {
return c.ShouldBindWith(obj, binding.XML)
@ -1139,6 +1144,12 @@ func (c *Context) JSON(code int, obj any) {
c.Render(code, render.JSON{Data: obj})
}
// MsgPack serializes the given struct as MsgPack into the response body.
// It also sets the Content-Type as "application/msgpack".
func (c *Context) MsgPack(code int, obj interface{}) {
c.Render(code, render.MsgPack{Data: obj})
}
// AsciiJSON serializes the given struct as JSON into the response body with unicode to ASCII string.
// It also sets the Content-Type as "application/json".
func (c *Context) AsciiJSON(code int, obj any) {