feat: 增加默认静态资源,及增加静态资源路由配置

This commit is contained in:
geeknonerd
2023-01-13 16:47:06 +08:00
parent ee58be7851
commit e6b72d7a7b
6 changed files with 7 additions and 0 deletions

View File

@@ -26,6 +26,8 @@ type envConfig struct {
DbConnMaxLifetimeHours int16 // 连接可复用的最大时间(小时)
Version string // 版本
Secret string // 系统加密字符
StaticPath string // 静态资源URL路径
StaticDirectory string // 静态资源本地路径
RedisPrefix string // Redis键前缀
UploadImageSize int64 // 上传图片限制
UploadVideoSize int64 // 上传视频限制
@@ -68,6 +70,10 @@ func loadConfig(path string) envConfig {
Version: "v1.0.0",
// 系统加密字符
Secret: "UVTIyzCy",
// 静态资源URL路径
StaticPath: "/api/static",
// 静态资源本地路径
StaticDirectory: "static",
// Redis键前缀
RedisPrefix: "Like:",
// 上传图片限制

View File

@@ -19,6 +19,7 @@ func initRouter() *gin.Engine {
router := gin.New()
// 设置静态路径
router.Static(config.Config.PublicPrefix, config.Config.UploadDirectory)
router.Static(config.Config.StaticPath, config.Config.StaticDirectory)
// 设置中间件
router.Use(gin.Logger(), middleware.Cors(), middleware.ErrorRecover())
// 特殊异常处理

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.4 KiB