ginx

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2023 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ANONYMOUS = iota
	ALLOW
)
View Source
const LocalDateTimeFormat string = "2006-01-02 15:04:05"

Variables

View Source
var Logger = logx.New(os.Stdout, "gin_log: ", log.LstdFlags)

Functions

func AccessLog

func AccessLog() gin.HandlerFunc

AccessLog 访问日志

func Auto

func Auto(c *gin.Context, err error)

Auto 增删改响应结果

func BindRequest

func BindRequest(c *gin.Context, obj interface{}) bool

BindRequest 绑定校验请求参数

func BindRequestAndCheck

func BindRequestAndCheck(c *gin.Context, obj any) bool

BindRequestAndCheck 绑定校验请求参数并校验

func BindRequestWithTranslates

func BindRequestWithTranslates(c *gin.Context, obj any) bool

func Check

func Check(c *gin.Context, obj any) bool

Check 校验必填项

func ContextTimeout

func ContextTimeout(t time.Duration) gin.HandlerFunc

ContextTimeout Context超时控制

func Error added in v0.0.3

func Error(c *gin.Context, msg string)

func Fail

func Fail(c *gin.Context, err *errorx.Error)

func Failx

func Failx(c *gin.Context, err *errorx.Error, appendMsg string)

func JSON added in v0.0.4

func JSON(c *gin.Context, obj any)

func MustInt added in v0.0.3

func MustInt(s string) int

func MustParamInt added in v0.0.3

func MustParamInt(c *gin.Context, key string) int

func MustParamInts added in v0.0.3

func MustParamInts(c *gin.Context, key string) []int

func MustQueryInt added in v0.0.3

func MustQueryInt(c *gin.Context, key string) int

func NewError added in v0.0.6

func NewError(text string) error

func RateLimiter

func RateLimiter(fillInterval time.Duration, capacity, quantum int64) gin.HandlerFunc

RateLimiter 限流

func Recovery

func Recovery() gin.HandlerFunc

Recovery 异常恢复

func ReturnJson

func ReturnJson(c *gin.Context, httpCode int, dataCode int, msg string)

func Success

func Success(c *gin.Context)

func TranslateError

func TranslateError(trans ut.Translator, err error) (validator.ValidationErrorsTranslations, bool)

TranslateError 把error翻译成中文

func TranslateErrorWithContext

func TranslateErrorWithContext(c *gin.Context, err error) (validator.ValidationErrorsTranslations, bool)

TranslateErrorWithContext 从Gin上下文中获取Translator翻译error成中文

func TranslateZH

func TranslateZH() gin.HandlerFunc

TranslateZH Gin校验信息翻译成中文

Types

type JsonTime added in v0.0.3

type JsonTime time.Time

func (JsonTime) MarshalJSON added in v0.0.3

func (j JsonTime) MarshalJSON() ([]byte, error)

func (*JsonTime) UnmarshalJSON added in v0.0.3

func (j *JsonTime) UnmarshalJSON(b []byte) error

type Router added in v0.0.5

type Router struct {
	*gin.Engine
	// contains filtered or unexported fields
}

func NewRouter added in v0.0.5

func NewRouter() *Router

func (*Router) Allow added in v0.0.9

func (r *Router) Allow(method string, path string)

func (*Router) Anonymous added in v0.0.9

func (r *Router) Anonymous(method string, path string)

func (*Router) DELETE added in v0.0.5

func (r *Router) DELETE(relativePath string, handlers ...gin.HandlerFunc) (string, string)

func (*Router) Exists added in v0.0.5

func (r *Router) Exists(retype int, method string, path string) bool

func (*Router) GET added in v0.0.5

func (r *Router) GET(relativePath string, handlers ...gin.HandlerFunc) (string, string)

func (*Router) POST added in v0.0.5

func (r *Router) POST(relativePath string, handlers ...gin.HandlerFunc) (string, string)

func (*Router) PUT added in v0.0.5

func (r *Router) PUT(relativePath string, handlers ...gin.HandlerFunc) (string, string)

Jump to

Keyboard shortcuts

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