ginmiddleware

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2023 License: GPL-3.0 Imports: 31 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AntiDDOS added in v1.3.5

func AntiDDOS() gin.HandlerFunc

AntiDDOS 阻止超流量ip

func Blacklist added in v1.3.5

func Blacklist(filename string) gin.HandlerFunc

Blacklist IP黑名单

func CFConnectingIP added in v1.3.3

func CFConnectingIP() gin.HandlerFunc

CFConnectingIP get cf ip

func CheckRequired

func CheckRequired(params ...string) gin.HandlerFunc

CheckRequired 检查必填参数

func CheckSecurityCode

func CheckSecurityCode(codeType string, codeRange int) gin.HandlerFunc

CheckSecurityCode 校验安全码 codeType: 安全码更新周期,h: 每小时更新,m: 每分钟更新 codeRange: 安全码容错范围(分钟)

func Clearlog

func Clearlog(c *gin.Context)

Clearlog 日志清理

func Delay

func Delay() gin.HandlerFunc

Delay 性能延迟

func GetSocketTimeout added in v1.3.3

func GetSocketTimeout() time.Duration

GetSocketTimeout 获取超时时间

func HideParams

func HideParams(params ...string) gin.HandlerFunc

HideParams 隐藏敏感参数值

func ListenAndServe

func ListenAndServe(port int, h *gin.Engine) error

ListenAndServe 启用监听 port:端口号 h: http.hander, like gin.New()

func ListenAndServeTLS

func ListenAndServeTLS(port int, h *gin.Engine, certfile, keyfile string, clientca ...string) error

ListenAndServeTLS 启用TLS监听 port:端口号 h: http.hander, like gin.New() certfile: cert file path keyfile: key file path clientca: 客户端根证书用于验证客户端合法性

func ListenAndServeWithOption added in v1.3.3

func ListenAndServeWithOption(opt *ServiceOption)

ListenAndServeWithOption 启动服务

func LiteEngine added in v1.3.3

func LiteEngine(logfile string, logDays int, hosts ...string) *gin.Engine

LiteEngine 轻量化基础引擎

func LogToWriter added in v1.3.5

func LogToWriter(w io.Writer, skippath ...string) gin.HandlerFunc

LogToWriter LogToWriter

func LoggerWithRolling

func LoggerWithRolling(logdir, filename string, maxdays int, skippath ...string) gin.HandlerFunc

LoggerWithRolling 滚动日志 logdir: 日志存放目录。 filename:日志文件名。 maxdays:日志文件最大保存天数。

func NewGinEngine

func NewGinEngine(logDir, logName string, logDays int, logLevel ...int) *gin.Engine

NewGinEngine 返回一个新的gin路由 logName:日志文件名 logDays:日志保留天数 logLevel:日志等级(已废弃)

func Page403

func Page403(c *gin.Context)

Page403 Page403

func Page404

func Page404(c *gin.Context)

Page404 Page404

func Page405

func Page405(c *gin.Context)

Page405 Page405

func Page500

func Page500(c *gin.Context)

Page500 Page500

func PageAbort added in v1.3.5

func PageAbort(c *gin.Context)

PageAbort PPageEmptyage403

func PageDefault

func PageDefault(c *gin.Context)

PageDefault 健康检查

func PageEmpty added in v1.3.3

func PageEmpty(c *gin.Context)

PageEmpty PPageEmptyage403

func RateLimit

func RateLimit(r, b int) gin.HandlerFunc

RateLimit 限流器,基于官方库

r: 每秒可访问次数,1-100
b: 缓冲区大小

func RateLimitWithIP

func RateLimitWithIP(r, b int) gin.HandlerFunc

RateLimitWithIP ip限流器,基于官方库

r: 每秒可访问次数,1-100
b: 缓冲区大小

func RateLimitWithTimeout added in v1.3.3

func RateLimitWithTimeout(r, b int, t time.Duration) gin.HandlerFunc

RateLimitWithTimeout 超时限流器,基于官方库

r: 每秒可访问次数,1-100
b: 缓冲区大小
t: 超时时长

func ReadCacheJSON

func ReadCacheJSON(mydb db.SQLInterface) gin.HandlerFunc

ReadCacheJSON 读取数据库缓存

func ReadCachePB2

func ReadCachePB2(mydb db.SQLInterface) gin.HandlerFunc

ReadCachePB2 读取数据库缓存

func ReadParams

func ReadParams() gin.HandlerFunc

ReadParams 读取请求的参数,保存到c.Params

func Recovery

func Recovery() gin.HandlerFunc

Recovery 错误恢复

func TLSRedirect

func TLSRedirect() gin.HandlerFunc

TLSRedirect tls重定向

func XForwardedIP added in v1.3.3

func XForwardedIP() gin.HandlerFunc

XForwardedIP 替换realip

Types

type ServiceOption added in v1.3.3

type ServiceOption struct {
	EngineFunc   func() *gin.Engine
	CertFile     string
	KeyFile      string
	HTTPPort     int
	HTTPSPort    int
	Hosts        []string
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
	Debug        bool
	LogFile      string
	LogDays      int
}

ServiceOption 通用化http框架

Jump to

Keyboard shortcuts

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