gin

package
v1.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 4, 2021 License: MIT Imports: 15 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NopHandlerFunc = gin.HandlerFunc(func(c *gin.Context) {
	if c == nil {
		return
	}
	c.Next()
})

Functions

func Bind

func Bind(ctx *gin.Context, obj interface{}) error

func DefaultBinding

func DefaultBinding(ctx *gin.Context) binding.Binding

Default returns the appropriate Binding instance based on the HTTP method and the content type.

func DefaultRender

func DefaultRender(ctx *gin.Context, obj interface{}) render.Render

DefaultRender returns the appropriate Binding instance based on the HTTP method and the content type.

func MustBind

func MustBind(ctx *gin.Context, obj interface{}) error

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 RecoverHandler(c *gin.Context, err interface{}) error

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 Redirect

func Redirect(code int, path string) gin.HandlerFunc

func RedirectTrim

func RedirectTrim(code int, prefix string) gin.HandlerFunc

func RequestIDFromGinContext

func RequestIDFromGinContext(ctx *gin.Context) string

func ShouldBind

func ShouldBind(ctx *gin.Context, obj interface{}) error

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL