This commit is contained in:
2026-07-02 19:56:13 +08:00
commit 083b6e5dbe
33 changed files with 4175 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
package main
import (
"net/http"
"strings"
"github.com/gin-gonic/gin"
)
func main() {
//启动gin服务
r := gin.Default()
// 静态文件服务
fs := http.FileServer(http.Dir("./dist"))
// 中间件处理路由
r.Use(func(c *gin.Context) {
if strings.HasPrefix(c.Request.URL.Path, "/api") {
c.Next() // 继续处理API请求
return
}
// 处理静态文件
fs.ServeHTTP(c.Writer, c.Request)
c.Abort()
})
r.Run()
}