refactor(doc): use space not tab (#1006)
This commit is contained in:
parent
02a6f9b6bc
commit
aa6d2d29f8
19
context.go
19
context.go
@ -85,8 +85,8 @@ func (c *Context) Copy() *Context {
|
|||||||
return &cp
|
return &cp
|
||||||
}
|
}
|
||||||
|
|
||||||
// HandlerName returns the main handler's name. For example if the handler is "handleGetUsers()", this
|
// HandlerName returns the main handler's name. For example if the handler is "handleGetUsers()",
|
||||||
// function will return "main.handleGetUsers"
|
// this function will return "main.handleGetUsers"
|
||||||
func (c *Context) HandlerName() string {
|
func (c *Context) HandlerName() string {
|
||||||
return nameOfFunction(c.handlers.Last())
|
return nameOfFunction(c.handlers.Last())
|
||||||
}
|
}
|
||||||
@ -117,8 +117,8 @@ func (c *Context) IsAborted() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Abort prevents pending handlers from being called. Note that this will not stop the current handler.
|
// 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
|
// Let's say you have an authorization middleware that validates that the current request is authorized.
|
||||||
// authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers
|
// If the authorization fails (ex: the password does not match), call Abort to ensure the remaining handlers
|
||||||
// for this request are not called.
|
// for this request are not called.
|
||||||
func (c *Context) Abort() {
|
func (c *Context) Abort() {
|
||||||
c.index = abortIndex
|
c.index = abortIndex
|
||||||
@ -132,15 +132,16 @@ func (c *Context) AbortWithStatus(code int) {
|
|||||||
c.Abort()
|
c.Abort()
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbortWithStatusJSON calls `Abort()` and then `JSON` internally. This method stops the chain, writes the status code and return a JSON body
|
// 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".
|
// It also sets the Content-Type as "application/json".
|
||||||
func (c *Context) AbortWithStatusJSON(code int, jsonObj interface{}) {
|
func (c *Context) AbortWithStatusJSON(code int, jsonObj interface{}) {
|
||||||
c.Abort()
|
c.Abort()
|
||||||
c.JSON(code, jsonObj)
|
c.JSON(code, jsonObj)
|
||||||
}
|
}
|
||||||
|
|
||||||
// AbortWithError calls `AbortWithStatus()` and `Error()` internally. This method stops the chain, writes the status code and
|
// AbortWithError calls `AbortWithStatus()` and `Error()` internally.
|
||||||
// pushes the specified error to `c.Errors`.
|
// This method stops the chain, writes the status code and pushes the specified error to `c.Errors`.
|
||||||
// See Context.Error() for more details.
|
// See Context.Error() for more details.
|
||||||
func (c *Context) AbortWithError(code int, err error) *Error {
|
func (c *Context) AbortWithError(code int, err error) *Error {
|
||||||
c.AbortWithStatus(code)
|
c.AbortWithStatus(code)
|
||||||
@ -153,8 +154,8 @@ func (c *Context) AbortWithError(code int, err error) *Error {
|
|||||||
|
|
||||||
// Error attaches an error to the current context. The error is pushed to a list of errors.
|
// Error attaches an error to the current context. The error is pushed to a list of errors.
|
||||||
// It's a good idea to call Error for each error that occurred during the resolution of a request.
|
// It's a good idea to call Error for each error that occurred during the resolution of a request.
|
||||||
// A middleware can be used to collect all the errors
|
// A middleware can be used to collect all the errors and push them to a database together,
|
||||||
// and push them to a database together, print a log, or append it in the HTTP response.
|
// print a log, or append it in the HTTP response.
|
||||||
// Error will panic if err is nil.
|
// Error will panic if err is nil.
|
||||||
func (c *Context) Error(err error) *Error {
|
func (c *Context) Error(err error) *Error {
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user