middleware

package
v0.0.0-...-0ffe074 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2024 License: Apache-2.0 Imports: 9 Imported by: 2

Documentation

Overview

Package middleware ...

Description : middleware ...

Author : go_developer@163.com<白茶清欢>

Date : 2022-07-14 10:53

Package middleware ...

Description : middleware ...

Author : go_developer@163.com<白茶清欢>

Date : 2022-06-25 23:07

Package middleware ...

Description : middleware ...

Author : go_developer@163.com<白茶清欢>

Date : 2022-06-25 23:24

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitRequest

func InitRequest() gin.HandlerFunc

InitRequest 初始化请求

Author : go_developer@163.com<白茶清欢>

Date : 23:08 2022/6/25

func LogRequest

func LogRequest(cfg *AccessConfig) gin.HandlerFunc

LogRequest 记录请求日志

Author : go_developer@163.com<白茶清欢>

Date : 10:55 2022/7/14

func ValidateBlackIPMiddleware

func ValidateBlackIPMiddleware(code interface{}, httpCode int, validateFunc define.IsBlackIP) gin.HandlerFunc

ValidateBlackIPMiddleware 验证黑名单IP的中间件

Author : go_developer@163.com<白茶清欢>

Date : 23:24 2022/6/25

func ValidateWhiteIPMiddleware

func ValidateWhiteIPMiddleware(code interface{}, httpCode int, validateFunc define.IsWhiteIP) gin.HandlerFunc

ValidateWhiteIPMiddleware 是否白名单IP

Author : go_developer@163.com<白茶清欢>

Date : 23:33 2022/6/25

Types

type AccessConfig

type AccessConfig struct {
	Logger             *zap.Logger                                                                                 // 日志实例
	RequestHeaderList  []string                                                                                    // 要记录哪些header , 不传全部记录
	ResponseHeaderList []string                                                                                    // 要记录哪些响应header, 不传全部记录
	IsRecordLog        func(ctx *gin.Context) bool                                                                 // 验证当前请求是否记录日志
	ExtraFieldList     []string                                                                                    // 记录的扩展字段列表,请将相关数据使用 ctx.Set 写入上下文中, 日志会自动记录
	FinishHook         func(ctx *gin.Context, requestData []byte, responseData map[string]interface{}, cost int64) // 请求处理完成之后, 触发的hook函数
}

AccessConfig 访问记录的配置

Author : go_developer@163.com<白茶清欢>

Date : 11:26 2022/7/14

Directories

Path Synopsis
Package request_cors ...
Package request_cors ...

Jump to

Keyboard shortcuts

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