Skip to content

Commit

Permalink
fix: build error
Browse files Browse the repository at this point in the history
  • Loading branch information
Mereithhh committed Dec 7, 2024
1 parent 4e91512 commit e5519f5
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ func Serve(urlPrefix string, fs ServeFileSystem) gin.HandlerFunc {
c.Abort()
} else {
path := c.Request.URL.Path
pathHasAdmin := strings.Contains(path, "/admin")
pathHasAPI := strings.Contains(path, "/api")
if !pathHasAdmin || pathHasAPI {
// pathHasAdmin := strings.Contains(path, "/admin")
// pathHasLogin := strings.Contains(path, "/login")
if pathHasAPI {
return
} else {
adminFile, err := fs.Open("index.html")
file, err := fs.Open("index.html")
if err != nil {
logger.LogError("文件不存在: %s", c.Request.URL.Path)
return
}
defer adminFile.Close()
defer file.Close()
// 把文件返回
http.ServeContent(c.Writer, c.Request, "index.html", time.Now(), adminFile)
http.ServeContent(c.Writer, c.Request, "index.html", time.Now(), file)
c.Abort()
}

Expand Down

0 comments on commit e5519f5

Please sign in to comment.