forked from mirror/gin
update docs for context.Abort
The docs were a little unclear as to how to use Abort, and how it will affect the current handler.
This commit is contained in:
parent
52fcc5dbf6
commit
1541a141ee
|
@ -101,10 +101,10 @@ func (c *Context) IsAborted() bool {
|
||||||
return c.index >= abortIndex
|
return c.index >= abortIndex
|
||||||
}
|
}
|
||||||
|
|
||||||
// Abort stops the system to continue calling the pending handlers in the chain.
|
// Abort prevents pending handlers from being called. Note that this will not stop the current execution context.
|
||||||
// Let's say you have an authorization middleware that validates if the request is authorized
|
// Let's say you have an authorization middleware that validates that the current request is authorized. If the
|
||||||
// if the authorization fails (the password does not match). This method (Abort()) should be called
|
// authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers
|
||||||
// in order to stop the execution of the actual handler.
|
// for this request are not called.
|
||||||
func (c *Context) Abort() {
|
func (c *Context) Abort() {
|
||||||
c.index = abortIndex
|
c.index = abortIndex
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue