serverx

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Validator *validator.Validate

Validator 参数校验工具

Functions

func BindHandler

func BindHandler(group *gin.RouterGroup, handlers ...any)

BindHandler 注册handler中的方法

func GetClientIP

func GetClientIP(ctx *gin.Context) string

func RenderError

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

RenderError 返回错误

func RenderSuccess

func RenderSuccess(c *gin.Context, data any)

RenderSuccess 返回成功

func Run

func Run(mode string, cfg Config, initRoutes func(engine *gin.Engine))

func WithAccesslog

func WithAccesslog() gin.HandlerFunc

func WithCasbin

func WithCasbin(cfg casbinx.Config) gin.HandlerFunc

WithCasbin casbin中间件

func WithCors

func WithCors(headers ...string) gin.HandlerFunc

WithCors 跨域

func WithJWT

func WithJWT(cfg Config, jwtCfg jwtx.Config) gin.HandlerFunc

WithJWT 返回JWT Handler

func WithTraceid

func WithTraceid() gin.HandlerFunc

Types

type Config

type Config struct {
	Addr        string   `mapstructure:"addr"`
	CorsHeaders []string `mapstructure:"cors-headers"`
	SwaggerUI   string   `mapstructure:"swagger-ui"`
	RoutePrefix string   `mapstructure:"route-prefix"`
	NonAuth     []string `mapstructure:"non-auth"`
}

Jump to

Keyboard shortcuts

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