middleware

package
v0.0.0-...-d61a02a Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2024 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 中的用户名存放在 gin.Context 的 XUsernameKey 键中.

func Authz

func Authz(a Auther) gin.HandlerFunc

Authz 是 Gin 中间件,用来进行请求授权.

func Cors

func Cors(c *gin.Context)

给 options 请求的返回头设置浏览器跨域.

func NoCache

func NoCache(c *gin.Context)

禁止客户端缓存 HTTP 请求的返回结果.

func RequestID

func RequestID() gin.HandlerFunc

给每一个 HTTP 请求的 context, response 中注入 `X-Request-ID` 键值对.

func Secure

func Secure(c *gin.Context)

添加一些安全和资源访问相关的 HTTP 头.

Types

type Auther

type Auther interface {
	Authorize(sub, obj, act string) (bool, error)
}

Auther 用来定义授权接口实现. sub: 操作主题,obj:操作对象, act:操作

Jump to

Keyboard shortcuts

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