MCPcopy
hub / github.com/gin-gonic/gin / AbortWithStatusJSON

Method AbortWithStatusJSON

context.go:230–233  ·  view source on GitHub ↗

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".

(code int, jsonObj any)

Source from the content-addressed store, hash-verified

228// This method stops the chain, writes the status code and return a JSON body.
229// It also sets the Content-Type as "application/json".
230func (c *Context) AbortWithStatusJSON(code int, jsonObj any) {
231 c.Abort()
232 c.JSON(code, jsonObj)
233}
234
235// AbortWithError calls `AbortWithStatus()` and `Error()` internally.
236// This method stops the chain, writes the status code and pushes the specified error to `c.Errors`.

Callers 1

Calls 2

AbortMethod · 0.95
JSONMethod · 0.95

Tested by 1