gin

package module
v1.2.115 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2024 License: MIT Imports: 15 Imported by: 4

Documentation

Index

Constants

View Source
const DateTime = "2006/01/02 - 15:04:05"

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 LogFormatter added in v1.2.88

func LogFormatter(layout string) func(param gin.LogFormatterParams) string

LogFormatter is the log format function gin.Logger middleware uses.

func LogFormatterWithExtra added in v1.2.99

func LogFormatterWithExtra(layout string, getExtra func(param gin.LogFormatterParams) string) func(param gin.LogFormatterParams) string

LogFormatterWithExtra is the log format function gin.Logger middleware uses with extra append {path}.

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

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 WrapGinF

func WrapGinF(f gin.HandlerFunc) http.HandlerFunc

WrapGinF is a helper function for wrapping gin.HandlerFunc Returns a http middleware

func XRequestId

func XRequestId(keys ...interface{}) gin.HandlerFunc

XRequestId returns a new server interceptors with x-request-id in context.

Types

type EmptyRecoveryOption

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

type RecoveryOption interface {
	// contains filtered or unexported methods
}

A RecoveryOption sets options.

func WithRecoveryHandler

func WithRecoveryHandler(f func(c *gin.Context, err interface{}) error) RecoveryOption

WithRecoveryHandler set a recover handler if panic

type RecoveryOptionFunc

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