完善
This commit is contained in:
parent
79e443c1f7
commit
f205d83a13
|
@ -14,11 +14,6 @@ func SetupRouter() *gin.Engine {
|
||||||
// Disable Console Color
|
// Disable Console Color
|
||||||
// gin.DisableConsoleColor()
|
// gin.DisableConsoleColor()
|
||||||
r := gin.Default()
|
r := gin.Default()
|
||||||
r.Use(middleware.SetStaticFileCache)
|
|
||||||
//gzip 因为一般会用nginx做反代时自动使用gzip,所以go这边本身可以不用
|
|
||||||
/*r.Use(gzip.Gzip(gzip.DefaultCompression, gzip.WithExcludedPaths([]string{
|
|
||||||
"/wp-includes/", "/wp-content/",
|
|
||||||
})))*/
|
|
||||||
r.SetFuncMap(template.FuncMap{
|
r.SetFuncMap(template.FuncMap{
|
||||||
"unescaped": func(s string) interface{} {
|
"unescaped": func(s string) interface{} {
|
||||||
return template.HTML(s)
|
return template.HTML(s)
|
||||||
|
@ -27,13 +22,19 @@ func SetupRouter() *gin.Engine {
|
||||||
return t.Format("2006年01月02日")
|
return t.Format("2006年01月02日")
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
loadTemplates(r, "**/*")
|
||||||
|
r.Use(middleware.SetStaticFileCache)
|
||||||
|
//gzip 因为一般会用nginx做反代时自动使用gzip,所以go这边本身可以不用
|
||||||
|
/*r.Use(gzip.Gzip(gzip.DefaultCompression, gzip.WithExcludedPaths([]string{
|
||||||
|
"/wp-includes/", "/wp-content/",
|
||||||
|
})))*/
|
||||||
|
|
||||||
f := static.Fs{FS: static.FsEx, Path: "wp-includes"}
|
f := static.Fs{FS: static.FsEx, Path: "wp-includes"}
|
||||||
r.StaticFS("/wp-includes", http.FS(f))
|
r.StaticFS("/wp-includes", http.FS(f))
|
||||||
r.StaticFS("/wp-content", http.FS(static.Fs{
|
r.StaticFS("/wp-content", http.FS(static.Fs{
|
||||||
FS: static.FsEx,
|
FS: static.FsEx,
|
||||||
Path: "wp-content",
|
Path: "wp-content",
|
||||||
}))
|
}))
|
||||||
loadTemplates(r, "**/*")
|
|
||||||
r.GET("/", index)
|
r.GET("/", index)
|
||||||
r.GET("/page/:page", index)
|
r.GET("/page/:page", index)
|
||||||
r.GET("/p/category/:category", index)
|
r.GET("/p/category/:category", index)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user