mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-12 00:28:37 +08:00
Merge 84a97ef73e13c71e757aaefddbaf9213e6bc3442 into e3118cc378d263454098924ebbde7e8d1dd2e904
This commit is contained in:
commit
fd8eee7e2a
11
context.go
11
context.go
@ -867,6 +867,11 @@ func (c *Context) ShouldBindJSON(obj any) error {
|
|||||||
return c.ShouldBindWith(obj, binding.JSON)
|
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).
|
// ShouldBindXML is a shortcut for c.ShouldBindWith(obj, binding.XML).
|
||||||
// It works like ShouldBindJSON but binds the request body as XML data.
|
// It works like ShouldBindJSON but binds the request body as XML data.
|
||||||
func (c *Context) ShouldBindXML(obj any) error {
|
func (c *Context) ShouldBindXML(obj any) error {
|
||||||
@ -1204,6 +1209,12 @@ func (c *Context) JSON(code int, obj any) {
|
|||||||
c.Render(code, render.JSON{Data: obj})
|
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.
|
// 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".
|
// It also sets the Content-Type as "application/json".
|
||||||
func (c *Context) AsciiJSON(code int, obj any) {
|
func (c *Context) AsciiJSON(code int, obj any) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user