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

Method AbortWithStatus

context.go:213–217  ·  view source on GitHub ↗

AbortWithStatus calls `Abort()` and writes the headers with the specified status code. For example, a failed attempt to authenticate a request could use: context.AbortWithStatus(401).

(code int)

Source from the content-addressed store, hash-verified

211// AbortWithStatus calls `Abort()` and writes the headers with the specified status code.
212// For example, a failed attempt to authenticate a request could use: context.AbortWithStatus(401).
213func (c *Context) AbortWithStatus(code int) {
214 c.Status(code)
215 c.Writer.WriteHeaderNow()
216 c.Abort()
217}
218
219// AbortWithStatusPureJSON calls `Abort()` and then `PureJSON` internally.
220// This method stops the chain, writes the status code and return a JSON body without escaping.

Callers 14

AbortWithErrorMethod · 0.95
TestMiddlewareAbortFunction · 0.80
TestPanicCleanFunction · 0.80
TestPanicWithAbortFunction · 0.80
TestCustomRecoveryFunction · 0.80
defaultHandleRecoveryFunction · 0.80
BasicAuthForRealmFunction · 0.80
BasicAuthForProxyFunction · 0.80

Calls 3

StatusMethod · 0.95
AbortMethod · 0.95
WriteHeaderNowMethod · 0.65

Tested by 10

TestMiddlewareAbortFunction · 0.64
TestPanicCleanFunction · 0.64
TestPanicWithAbortFunction · 0.64
TestCustomRecoveryFunction · 0.64
TestRouterNotFoundFunction · 0.64