package handlers import ( "net/http" "os" "gateway/utils" "github.com/gin-gonic/gin" ) // 处理首页请求 func ServeIndex(c *gin.Context) { utils.LogAccess(c.ClientIP(), c.Request.URL.Path, c.Request.Method) http.ServeFile(c.Writer, c.Request, "./static/index.html") } // 处理静态文件请求 func ServeStatic(c *gin.Context) { utils.LogAccess(c.ClientIP(), c.Request.URL.Path, c.Request.Method) filePath := "./static" + c.Request.URL.Path if _, err := os.Stat(filePath); err == nil { http.ServeFile(c.Writer, c.Request, filePath) } else { c.AbortWithStatus(http.StatusNotFound) } }