Documentation ¶
Overview ¶
Package ginmiddleware 基于gin的web框架封装
Index ¶
- func BasicAuth(accountpairs ...string) gin.HandlerFunc
- func Blacklist(excludePath ...string) gin.HandlerFunc
- func CFConnectingIP() gin.HandlerFunc
- func CheckRequired(params ...string) gin.HandlerFunc
- func CheckSecurityCode(codeType string, codeRange int) gin.HandlerFunc
- func Clearlog(c *gin.Context)
- func Delay() gin.HandlerFunc
- func GetSocketTimeout() time.Duration
- func HideParams(params ...string) gin.HandlerFunc
- func ListenAndServe(port int, h *gin.Engine) error
- func ListenAndServeTLS(port int, h *gin.Engine, certfile, keyfile string, clientca ...string) error
- func ListenAndServeWithOption(opt *ServiceOption)
- func LiteEngine(logfile string, logDays int, hosts ...string) *gin.Engine
- func LogToWriter(w io.Writer, skippath ...string) gin.HandlerFunc
- func LoggerWithRolling(logdir, filename string, maxdays int, skippath ...string) gin.HandlerFunc
- func Page403(c *gin.Context)
- func Page404(c *gin.Context)
- func Page404Big(c *gin.Context)
- func Page404Rand(c *gin.Context)
- func Page405(c *gin.Context)
- func PageAbort(c *gin.Context)
- func PageDefault(c *gin.Context)
- func PageDev(c *gin.Context)
- func PageEmpty(c *gin.Context)
- func RateLimit(r, b int) gin.HandlerFunc
- func ReadCacheJSON(mydb db.SQLInterface) gin.HandlerFunc
- func ReadCachePB2(mydb db.SQLInterface) gin.HandlerFunc
- func ReadParams() gin.HandlerFunc
- func Recovery() gin.HandlerFunc
- func TLSRedirect() gin.HandlerFunc
- func XForwardedIP() gin.HandlerFunc
- type ServiceOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuth ¶
func BasicAuth(accountpairs ...string) gin.HandlerFunc
BasicAuth 返回basicauth信息
使用`username:password`格式提交
func CheckSecurityCode ¶
func CheckSecurityCode(codeType string, codeRange int) gin.HandlerFunc
CheckSecurityCode 校验安全码 codeType: 安全码更新周期,h: 每小时更新,m: 每分钟更新 codeRange: 安全码容错范围(分钟)
func ListenAndServe ¶
ListenAndServe 启用监听 port:端口号 h: http.hander, like gin.New()
func ListenAndServeTLS ¶
ListenAndServeTLS 启用TLS监听 port:端口号 h: http.hander, like gin.New() certfile: cert file path keyfile: key file path clientca: 客户端根证书用于验证客户端合法性
func ListenAndServeWithOption ¶
func ListenAndServeWithOption(opt *ServiceOption)
ListenAndServeWithOption 启动服务
func LiteEngine ¶
LiteEngine 轻量化基础引擎
func LogToWriter ¶
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 Page404Rand ¶
func RateLimit ¶
func RateLimit(r, b int) gin.HandlerFunc
RateLimit 限流器,基于uber-go
r: 每秒可访问次数,1-100 b: 缓冲区大小
Types ¶
type ServiceOption ¶
type ServiceOption struct { EngineFunc func() *gin.Engine Engine *gin.Engine Hosts []string CertFile string KeyFile string LogFile string ReadTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration HTTPPort string HTTPSPort string LogDays int Debug bool }
ServiceOption 通用化http框架
Click to show internal directories.
Click to hide internal directories.