mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 00:01:10 +08:00
[backport] add smart-git api
This commit is contained in:
parent
b5db6bcccc
commit
0e7abf3411
1 changed files with 12 additions and 1 deletions
13
api/api.go
13
api/api.go
|
|
@ -15,7 +15,7 @@ var (
|
|||
|
||||
var (
|
||||
logw = logger.Logw
|
||||
LogDump = logger.LogDump
|
||||
logDump = logger.LogDump
|
||||
logDebug = logger.LogDebug
|
||||
logInfo = logger.LogInfo
|
||||
logWarning = logger.LogWarning
|
||||
|
|
@ -59,6 +59,9 @@ func InitHandleRouter(cfg *config.Config, router *gin.Engine, version string) {
|
|||
apiRouter.GET("/rate_limit/limit", func(c *gin.Context) {
|
||||
RateLimitLimitHandler(c, cfg)
|
||||
})
|
||||
apiRouter.GET("/smartgit/status", func(c *gin.Context) {
|
||||
SmartGitStatusHandler(c, cfg)
|
||||
})
|
||||
}
|
||||
logInfo("API router Init success")
|
||||
}
|
||||
|
|
@ -127,3 +130,11 @@ func RateLimitLimitHandler(c *gin.Context, cfg *config.Config) {
|
|||
"RatePerMinute": cfg.RateLimit.RatePerMinute,
|
||||
})
|
||||
}
|
||||
|
||||
func SmartGitStatusHandler(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{}{
|
||||
"enabled": cfg.GitClone.Mode == "cache",
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue