Skip to content

Commit

Permalink
简化静态资源调用
Browse files Browse the repository at this point in the history
  • Loading branch information
Jrohy committed Apr 3, 2021
1 parent 199a1e6 commit 2297d14
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,16 +137,12 @@ func commonRouter(router *gin.Engine) {
}

func staticRouter(router *gin.Engine) {
// 设置静态资源
staticFs, _ := fs.Sub(f, "templates/static")
router.StaticFS("/static", http.FS(staticFs))

router.GET("/", func(c *gin.Context) {
c.Writer.WriteHeader(http.StatusOK)
indexHTML, _ := f.ReadFile("templates/" + "index.html")
c.Writer.Write(indexHTML)
c.Writer.Header().Add("Accept", "text/html")
c.Writer.Flush()
})
}

Expand Down

0 comments on commit 2297d14

Please sign in to comment.