middleware

package
v0.0.0-...-4f9d474 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const UsernameKey = "username"

UsernameKey 在 Gin 上下文中定义代表秘钥所有者的 Key.

View Source
const XRequestIDKey = "X-Request-ID"

XRequestIDKey 用来定义 Gin 上下文中的键,代表请求的 uuid.

Variables

View Source
var Middlewares = defaultMiddlewares()

Middlewares 存储所有支持的中间件.

Functions

func Context

func Context() gin.HandlerFunc

Context 是一个 Gin 中间件,将公共 Key 注入到上下文中.

func Cors

func Cors() gin.HandlerFunc

Cors 是一个 Gin 中间件,用于开启 CORS 支持.

func NoCache

func NoCache(c *gin.Context)

NoCache 是一个 Gin 中间件,用来禁止客户端缓存 HTTP 请求的返回结果.

func Options

func Options(c *gin.Context)

Options 是一个 Gin 中间件,用来设置 options 请求的返回头,然后退出中间件链,并结束请求(浏览器跨域设置).

func RequestID

func RequestID() gin.HandlerFunc

RequestID 是一个 Gin 中间件,用来在每一个 HTTP 请求的 context, response 中注入 `X-Request-ID` 键值对.

func Secure

func Secure(c *gin.Context)

Secure 是一个 Gin 中间件,用来添加一些安全和资源访问相关的 HTTP 头.

Types

type AuthOperator

type AuthOperator struct {
	// contains filtered or unexported fields
}

AuthOperator 用于切换不同的身份认证策略.

func (*AuthOperator) AuthFunc

func (o *AuthOperator) AuthFunc() gin.HandlerFunc

AuthFunc 执行身份认证.

func (*AuthOperator) SetStrategy

func (o *AuthOperator) SetStrategy(strategy AuthStrategy)

SetStrategy 用于设置身份认证策略.

type AuthStrategy

type AuthStrategy interface {
	AuthFunc() gin.HandlerFunc
}

AuthStrategy 身份认证策略,定义了身份认证的方法.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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