mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-15 21:06:39 +08:00
Add JSONAPI support to context
This commit is contained in:
parent
00f1c2af30
commit
19bf52b5bd
@ -331,6 +331,15 @@ func (c *Context) JSON(code int, obj interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Serializes the given struct as JSON into the response body.
|
||||||
|
// It also sets the Content-Type as "application/vnd.api+json".
|
||||||
|
func (c *Context) JSONAPI(code int, obj interface{}) {
|
||||||
|
c.writermem.WriteHeader(code)
|
||||||
|
if err := render.WriteJSONAPI(c.Writer, obj); err != nil {
|
||||||
|
c.renderError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Serializes the given struct as XML into the response body.
|
// Serializes the given struct as XML into the response body.
|
||||||
// It also sets the Content-Type as "application/xml".
|
// It also sets the Content-Type as "application/xml".
|
||||||
func (c *Context) XML(code int, obj interface{}) {
|
func (c *Context) XML(code int, obj interface{}) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user