middleware

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Authn

func Authn() gin.HandlerFunc

Authn 是认证中间件,用来从 gin.Context 中提取 token 并验证 token 是否合法, 如果合法则将 token 中的 sub 作为<用户名>存放在 gin.Context 的 XUsernameKey 键中.

func CORS

func CORS() gin.HandlerFunc

CORS 是跨域资源共享中间件,用来处理跨域请求

func Cors

func Cors(c *gin.Context)

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

func NoCache

func NoCache(c *gin.Context)

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

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

This section is empty.

Jump to

Keyboard shortcuts

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