Update main.go
Browse files
main.go
CHANGED
@@ -87,16 +87,16 @@ func main() {
|
|
87 |
r.Use(corsMiddleware())
|
88 |
// 1. 映射 Web 目录到 /web 路由
|
89 |
//r.Static("/web", "./web") // 确保 ./web 文件夹存在,并包含 index.html
|
90 |
-
subFS, err := fs.Sub(staticFiles, "web")
|
91 |
-
if err != nil {
|
92 |
-
|
93 |
-
}
|
94 |
-
r.StaticFS("/web", http.FS(subFS))
|
95 |
-
|
96 |
-
|
97 |
-
r.GET("/", func(c *gin.Context) {
|
98 |
-
|
99 |
-
})
|
100 |
// r.GET("/", func(c *gin.Context) {
|
101 |
// c.JSON(http.StatusOK, gin.H{"message": "API 服务运行中~"})
|
102 |
// })
|
|
|
87 |
r.Use(corsMiddleware())
|
88 |
// 1. 映射 Web 目录到 /web 路由
|
89 |
//r.Static("/web", "./web") // 确保 ./web 文件夹存在,并包含 index.html
|
90 |
+
//subFS, err := fs.Sub(staticFiles, "web")
|
91 |
+
//if err != nil {
|
92 |
+
// log.Fatal(err)
|
93 |
+
//}
|
94 |
+
//r.StaticFS("/web", http.FS(subFS))
|
95 |
+
|
96 |
+
//// 2. 根路径重定向到 /web
|
97 |
+
//r.GET("/", func(c *gin.Context) {
|
98 |
+
// c.Redirect(http.StatusMovedPermanently, "/web")
|
99 |
+
//})
|
100 |
// r.GET("/", func(c *gin.Context) {
|
101 |
// c.JSON(http.StatusOK, gin.H{"message": "API 服务运行中~"})
|
102 |
// })
|