mirror of
https://github.com/WJQSERVER-STUDIO/ghproxy.git
synced 2026-02-03 08:11:11 +08:00
24w18e
This commit is contained in:
parent
c50f23c399
commit
e5d941414e
11 changed files with 51 additions and 9 deletions
18
main.go
18
main.go
|
|
@ -75,13 +75,23 @@ func init() {
|
|||
gin.SetMode(gin.ReleaseMode)
|
||||
|
||||
router = gin.Default()
|
||||
router.UseH2C = true
|
||||
|
||||
setupApi(cfg, router)
|
||||
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
c.String(http.StatusForbidden, "403 Forbidden This route is not allowed to access.")
|
||||
LogWarning("Forbidden: IP:%s UA:%s METHOD:%s", c.ClientIP(), c.Request.UserAgent(), c.Request.Method)
|
||||
})
|
||||
if cfg.Page.Enabled {
|
||||
indexPagePath := fmt.Sprintf("%s/index.html", cfg.Page.StaticDir)
|
||||
faviconPath := fmt.Sprintf("%s/favicon.ico", cfg.Page.StaticDir)
|
||||
// 静态index页
|
||||
router.StaticFile("/", indexPagePath)
|
||||
// 静态favicon.ico
|
||||
router.StaticFile("/favicon.ico", faviconPath)
|
||||
} else if !cfg.Page.Enabled {
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
c.String(http.StatusForbidden, "403 Forbidden This route is not allowed to access.")
|
||||
LogWarning("Forbidden: IP:%s UA:%s METHOD:%s HTTPv:%s", c.ClientIP(), c.Request.UserAgent(), c.Request.Method, c.Request.Proto)
|
||||
})
|
||||
}
|
||||
|
||||
// 未匹配路由处理
|
||||
router.NoRoute(func(c *gin.Context) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue