middleware

package
v0.0.0-...-a3253b1 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestIdKey = "X-Request-Id"
)

Variables

This section is empty.

Functions

func Agent

func Agent(agent string) gin.HandlerFunc

Agent 设置服务agent

func Cors

func Cors(option CorsOption) gin.HandlerFunc

Cors 跨域中间件

func Https

func Https(addr string, redirect bool) gin.HandlerFunc

Https HTTPS处理

func Logger

func Logger(option xlog.Config) gin.HandlerFunc

Logger 日志

func Recovery

func Recovery(option xlog.Config) gin.HandlerFunc

Recovery 异常恢复

func RequestId

func RequestId() gin.HandlerFunc

RequestId 请求ID

Types

type CorsOption

type CorsOption struct {
	Open             bool   `json:"open" yaml:"open"`                         // Open 是否开启跨域
	MaxAge           int    `json:"maxAge" yaml:"maxAge"`                     // MaxAge
	AllowOrigin      string `json:"allowOrigin" yaml:"allowOrigin"`           // AllowOrigin 允许域名
	AllowHeaders     string `json:"allowHeaders" yaml:"allowHeaders"`         // AllowHeaders 允许Header参数
	AllowMethods     string `json:"allowMethods" yaml:"allowMethods"`         // AllowMethods 允许跨域的请求方式
	ExposeHeaders    string `json:"exposeHeaders" yaml:"exposeHeaders"`       // ExposeHeaders 暴露的header参数
	AllowCredentials string `json:"allowCredentials" yaml:"allowCredentials"` // AllowCredentials 允许https
}

CorsOption 跨域配置

Jump to

Keyboard shortcuts

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