mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 12:12:12 +08:00
feat: added AbortWithStatusPureJSON()
in context
This commit is contained in:
parent
76dd08d512
commit
7d36764260
@ -216,6 +216,14 @@ func (c *Context) AbortWithStatus(code int) {
|
|||||||
c.Abort()
|
c.Abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// AbortWithStatusJSON calls `Abort()` and then `PureJSON` internally.
|
||||||
|
// This method stops the chain, writes the status code and return a JSON body without escaping.
|
||||||
|
// It also sets the Content-Type as "application/json".
|
||||||
|
func (c *Context) AbortWithStatusPureJSON(code int, jsonObj any) {
|
||||||
|
c.Abort()
|
||||||
|
c.PureJSON(code, jsonObj)
|
||||||
|
}
|
||||||
|
|
||||||
// AbortWithStatusJSON calls `Abort()` and then `JSON` internally.
|
// AbortWithStatusJSON calls `Abort()` and then `JSON` internally.
|
||||||
// This method stops the chain, writes the status code and return a JSON body.
|
// This method stops the chain, writes the status code and return a JSON body.
|
||||||
// It also sets the Content-Type as "application/json".
|
// It also sets the Content-Type as "application/json".
|
||||||
|
Loading…
x
Reference in New Issue
Block a user