feat: added AbortWithStatusPureJSON() in Context (#4290)

* feat: added `AbortWithStatusPureJSON()` in context

* Update context_test.go
This commit is contained in:
Denny Septian Panggabean
2025-07-13 08:40:35 +07:00
committed by GitHub
parent b7d6308bcc
commit dbd8a25150
2 changed files with 34 additions and 0 deletions
+8
View File
@@ -216,6 +216,14 @@ func (c *Context) AbortWithStatus(code int) {
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.
// This method stops the chain, writes the status code and return a JSON body.
// It also sets the Content-Type as "application/json".