Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var MiddlewareLimiter = func(conf *g2util.Config) gin.HandlerFunc { requestsPerSecond := conf.Viper().GetFloat64("http_server.limit") if requestsPerSecond < 1 { requestsPerSecond = float64(5) } lmt := tollbooth.NewLimiter(requestsPerSecond, nil) return func(c *gin.Context) { httpError := tollbooth.LimitByRequest(lmt, c.Writer, c.Request) if httpError != nil { lmt.ExecOnLimitReached(c.Writer, c.Request) JSONP(c, httpError.StatusCode, httpError.Message) c.Abort() return } c.Next() } }
MiddlewareLimiter ...
Functions ¶
Types ¶
type G2gin ¶
type G2gin struct { Config *g2util.Config `inject:""` AbFile *g2util.AbFile `inject:""` Graceful *g2util.Graceful `inject:""` // contains filtered or unexported fields }
G2gin ...
type ItfGinRouter ¶
type ItfGinRouter interface { Router(g *gin.RouterGroup) J2rpc(jsv j2rpc.RPCServer) }
ItfGinRouter ...gin router interface
type JSONResponse ¶ added in v2.2.1
type JSONResponse struct { Code int `json:"code"` Msg string `json:"msg,omitempty"` Data interface{} `json:"data,omitempty"` }
JSONResponse ...
Click to show internal directories.
Click to hide internal directories.