gin

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthnMiddleware

func AuthnMiddleware(retriever UserRetriever) gin.HandlerFunc

AuthnMiddleware 是一个认证中间件,用于从 gin.Context 中提取 token 并验证 token 是否合法.

func AuthzMiddleware

func AuthzMiddleware(authorizer Authorizer) gin.HandlerFunc

AuthzMiddleware 是一个 Gin 中间件,用于进行请求授权.

func Cors

func Cors(c *gin.Context)

Cors是一个 Gin 中间件,用于处理 CORS 请求.

func NoCache

func NoCache(c *gin.Context)

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

func RequestIDMiddleware

func RequestIDMiddleware() gin.HandlerFunc

RequestIDMiddleware 是一个 Gin 中间件,用于在每个 HTTP 请求的上下文和 响应中注入 `x-request-id` 键值对.

func Secure

func Secure(c *gin.Context)

Secure 是一个 Gin 中间件,用于添加安全相关的 HTTP 头.

Types

type Authorizer

type Authorizer interface {
	Authorize(subject, object, action string) (bool, error)
}

Authorizer 用于定义授权接口的实现.

type UserRetriever

type UserRetriever interface {
	// GetUser 根据用户ID获取用户信息
	GetUser(ctx context.Context, userID string) (*model.UserM, error)
}

UserRetriever 用于根据用户名获取用户的接口.

Jump to

Keyboard shortcuts

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