Abort prevents pending handlers from being called. Note that this will not stop the current handler. Let's say you have an authorization middleware that validates that the current request is authorized. If the authorization fails (ex: the password does not match), call Abort to ensure the remaining
()
| 205 | // If the authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers |
| 206 | // for this request are not called. |
| 207 | func (c *Context) Abort() { |
| 208 | c.index = abortIndex |
| 209 | } |
| 210 | |
| 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). |
no outgoing calls