diff --git a/conf.yml.example b/conf.yml.example index 5f8317fe..2509e681 100644 --- a/conf.yml.example +++ b/conf.yml.example @@ -13,6 +13,7 @@ server: address: "0.0.0.0" port: "5244" search: true + download: true //是否允许获取直链 static: dist site_url: '*' password: password #用于重建目录 diff --git a/conf/config.go b/conf/config.go index 7d330b22..b65070d7 100644 --- a/conf/config.go +++ b/conf/config.go @@ -32,8 +32,9 @@ type Config struct { } `yaml:"info"` Server struct { Address string `yaml:"address"` - Port string `yaml:"port"` //端口 - Search bool `yaml:"search"` //允许搜索 + Port string `yaml:"port"` //端口 + Search bool `yaml:"search"` //允许搜索 + Download bool `yaml:"download"` //允许下载 Static string `yaml:"static"` SiteUrl string `yaml:"site_url"` //网站url Password string `yaml:"password"` diff --git a/server/router.go b/server/router.go index 9e0d6215..1cb2cbb7 100644 --- a/server/router.go +++ b/server/router.go @@ -16,11 +16,11 @@ func InitRouter(engine *gin.Engine) { engine.NoRoute(func(c *gin.Context) { c.File(conf.Conf.Server.Static + "/index.html") }) - InitApiRouter(engine) + InitApiRouter(engine, conf.Conf.Server.Download) } // init api router -func InitApiRouter(engine *gin.Engine) { +func InitApiRouter(engine *gin.Engine, download bool) { apiV2 := engine.Group("/api") { apiV2.GET("/info", controllers.Info) @@ -32,5 +32,7 @@ func InitApiRouter(engine *gin.Engine) { apiV2.POST("/global_search", controllers.GlobalSearch) apiV2.POST("/rebuild", controllers.RebuildTree) } - engine.GET("/d/*path", controllers.Down) + if download { + engine.GET("/d/*path", controllers.Down) + } }