Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
Context
func (*Context) Abort ¶
func (c *Context) Abort()
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 handlers for this request are not called.
func (*Context) Error ¶
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. A middleware can be used to collect all the errors and push them to a database together, print a log, or append it in the HTTP response. Error will panic if err is nil.
func (*Context) Next ¶
func (c *Context) Next()
Next should be used only inside middleware. It executes the pending handlers in the chain inside the calling handler. See example in GitHub.
func (*Context) Use ¶
func (c *Context) Use(middleware ...HandlerFunc) *Context
Use attaches a global middleware to the router. ie. the middleware attached though Use() will be For example, this is the right place for a logger or error management middleware.
type Data ¶
type Data struct { Err error `json:"err,omitempty"` Data interface{} `json:"data"` }
Context Data
type HandlerFunc ¶
type HandlerFunc func(*Context)
HandlerFunc defines the handler used by gin middleware as return value.