Documentation
¶
Index ¶
- Variables
- func Bind(ctx *gin.Context, obj interface{}) error
- func DefaultBinding(ctx *gin.Context) binding.Binding
- func DefaultRender(ctx *gin.Context, obj interface{}) render.Render
- func MustBind(ctx *gin.Context, obj interface{}) error
- func RecoverHandler(c *gin.Context, err interface{}) error
- func Recovery(opts ...RecoveryOption) gin.HandlerFunc
- func RecoveryWithWriter(out io.Writer, opts ...RecoveryOption) gin.HandlerFunc
- func Redirect(code int, path string) gin.HandlerFunc
- func RedirectTrim(code int, prefix string) gin.HandlerFunc
- func RequestIDFromGinContext(ctx *gin.Context) string
- func ShouldBind(ctx *gin.Context, obj interface{}) error
- func UseHTTPPreflight() gin.HandlerFunc
- func UseNegroni(n *negroni.Negroni) gin.HandlerFunc
- func XRequestId(keys ...interface{}) gin.HandlerFunc
- type EmptyRecoveryOption
- type RecoveryOption
- type RecoveryOptionFunc
Constants ¶
This section is empty.
Variables ¶
var NopHandlerFunc = gin.HandlerFunc(func(c *gin.Context) { if c == nil { return } c.Next() })
Functions ¶
func DefaultBinding ¶
Default returns the appropriate Binding instance based on the HTTP method and the content type.
func DefaultRender ¶
DefaultRender returns the appropriate Binding instance based on the HTTP method and the content type.
func MustBind ¶
MustBindWith binds the passed struct pointer using the specified binding engine. It will abort the request with HTTP 400 if any error occurs. See the binding package.
func RecoverHandler ¶ added in v0.0.122
func Recovery ¶
func Recovery(opts ...RecoveryOption) gin.HandlerFunc
Recovery returns a middleware that recovers from any panics and writes a 500 if there was one.
func RecoveryWithWriter ¶
func RecoveryWithWriter(out io.Writer, opts ...RecoveryOption) gin.HandlerFunc
RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
func RedirectTrim ¶
func RedirectTrim(code int, prefix string) gin.HandlerFunc
func RequestIDFromGinContext ¶
func ShouldBind ¶
ShouldBind binds the passed struct pointer using the specified binding engine. See the binding package.
func UseHTTPPreflight ¶
func UseHTTPPreflight() gin.HandlerFunc
func UseNegroni ¶
func UseNegroni(n *negroni.Negroni) gin.HandlerFunc
WrapGinF is a helper function for wrapping gin.HandlerFunc Returns a negroni middleware
func XRequestId ¶
func XRequestId(keys ...interface{}) gin.HandlerFunc
XRequestId returns a new server interceptors with x-request-id in context.
Types ¶
type EmptyRecoveryOption ¶ added in v0.0.122
type EmptyRecoveryOption struct{}
EmptyRecoveryOption does not alter the configuration. It can be embedded in another structure to build custom options.
This API is EXPERIMENTAL.
type RecoveryOption ¶ added in v0.0.122
type RecoveryOption interface {
// contains filtered or unexported methods
}
A RecoveryOption sets options.
func WithRecoveryHandler ¶ added in v0.0.122
func WithRecoveryHandler(f func(c *gin.Context, err interface{}) error) RecoveryOption
WithRecoveryHandler set a recover handler if panic
type RecoveryOptionFunc ¶ added in v0.0.122
type RecoveryOptionFunc func(*recovery)
RecoveryOptionFunc wraps a function that modifies recovery into an implementation of the RecoveryOption interface.