mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
24w21d
This commit is contained in:
parent
e32adadaff
commit
267dfafcb9
10 changed files with 154 additions and 35 deletions
11
api/api.go
11
api/api.go
|
|
@ -44,6 +44,9 @@ func InitHandleRouter(cfg *config.Config, router *gin.Engine, version string) {
|
|||
apiRouter.GET("/rate_limit/status", func(c *gin.Context) {
|
||||
RateLimitStatusHandler(c, cfg)
|
||||
})
|
||||
apiRouter.GET("/rate_limit/limit", func(c *gin.Context) {
|
||||
RateLimitLimitHandler(c, cfg)
|
||||
})
|
||||
}
|
||||
logInfo("API router Init success")
|
||||
}
|
||||
|
|
@ -104,3 +107,11 @@ func RateLimitStatusHandler(c *gin.Context, cfg *config.Config) {
|
|||
"RateLimit": cfg.RateLimit.Enabled,
|
||||
})
|
||||
}
|
||||
|
||||
func RateLimitLimitHandler(c *gin.Context, cfg *config.Config) {
|
||||
logInfo("%s %s %s %s %s", c.ClientIP(), c.Request.Method, c.Request.URL.Path, c.Request.UserAgent(), c.Request.Proto)
|
||||
c.Writer.Header().Set("Content-Type", "application/json")
|
||||
json.NewEncoder(c.Writer).Encode(map[string]interface{}{
|
||||
"RatePerMinute": cfg.RateLimit.RatePerMinute,
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue