是否开启gzip
This commit is contained in:
parent
6704b5b486
commit
111f83ec88
@ -51,3 +51,5 @@ singleIpSearchNum: 10
|
||||
maxPostIdCacheTime: 1h
|
||||
# 用户信息缓存时间
|
||||
userInfoCacheTime: 24h
|
||||
# Gzip
|
||||
gzip: false
|
||||
|
5
go.mod
5
go.mod
@ -3,6 +3,9 @@ module github/fthvgb1/wp-go
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
github.com/dlclark/regexp2 v1.7.0
|
||||
github.com/gin-contrib/gzip v0.0.6
|
||||
github.com/gin-contrib/pprof v1.4.0
|
||||
github.com/gin-contrib/sessions v0.0.5
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/go-sql-driver/mysql v1.6.0
|
||||
@ -11,8 +14,6 @@ require (
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/dlclark/regexp2 v1.7.0 // indirect
|
||||
github.com/gin-contrib/pprof v1.4.0 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
|
@ -1,6 +1,7 @@
|
||||
package route
|
||||
|
||||
import (
|
||||
"github.com/gin-contrib/gzip"
|
||||
"github.com/gin-contrib/pprof"
|
||||
"github.com/gin-contrib/sessions"
|
||||
"github.com/gin-contrib/sessions/cookie"
|
||||
@ -10,6 +11,7 @@ import (
|
||||
"github/fthvgb1/wp-go/middleware"
|
||||
"github/fthvgb1/wp-go/static"
|
||||
"github/fthvgb1/wp-go/templates"
|
||||
"github/fthvgb1/wp-go/vars"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"time"
|
||||
@ -29,10 +31,11 @@ func SetupRouter() *gin.Engine {
|
||||
}).SetTemplate()
|
||||
r.Use(gin.Logger(), middleware.FlowLimit(), gin.Recovery(), middleware.SetStaticFileCache)
|
||||
//gzip 因为一般会用nginx做反代时自动使用gzip,所以go这边本身可以不用
|
||||
/*r.Use(gzip.Gzip(gzip.DefaultCompression, gzip.WithExcludedPaths([]string{
|
||||
if vars.Conf.Gzip {
|
||||
r.Use(gzip.Gzip(gzip.DefaultCompression, gzip.WithExcludedPaths([]string{
|
||||
"/wp-includes/", "/wp-content/",
|
||||
})))*/
|
||||
|
||||
})))
|
||||
}
|
||||
f := static.Fs{FS: static.FsEx, Path: "wp-includes"}
|
||||
r.StaticFileFS("/favicon.ico", "favicon.ico", http.FS(static.FsEx))
|
||||
r.StaticFS("/wp-includes", http.FS(f))
|
||||
|
@ -30,6 +30,7 @@ type Config struct {
|
||||
SingleIpSearchNum int64 `yaml:"singleIpSearchNum"`
|
||||
MaxPostIdCacheTime time.Duration `yaml:"maxPostIdCacheTime"`
|
||||
UserInfoCacheTime time.Duration `yaml:"userInfoCacheTime"`
|
||||
Gzip bool `yaml:"gzip"`
|
||||
}
|
||||
|
||||
type Mysql struct {
|
||||
|
Loading…
Reference in New Issue
Block a user