add i18n step1
This commit is contained in:
parent
34d553a890
commit
79e3db6078
23 changed files with 2309 additions and 450 deletions
33
main.go
33
main.go
|
|
@ -15,10 +15,12 @@ import (
|
|||
"os"
|
||||
"time"
|
||||
|
||||
"github.com/fenthope/compress"
|
||||
"github.com/fenthope/record"
|
||||
"github.com/fenthope/sessions"
|
||||
"github.com/fenthope/sessions/cookie"
|
||||
"github.com/infinite-iroha/touka"
|
||||
"github.com/klauspost/compress/zstd"
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
|
|
@ -117,6 +119,37 @@ func main() {
|
|||
r := touka.Default()
|
||||
r.Use(record.Middleware())
|
||||
|
||||
r.Use(compress.Compression(compress.CompressOptions{
|
||||
// Algorithms: 配置每种压缩算法的级别和是否启用对象池
|
||||
Algorithms: map[string]compress.AlgorithmConfig{
|
||||
compress.EncodingGzip: {
|
||||
Level: -1, // Gzip最高压缩比
|
||||
PoolEnabled: true, // 启用Gzip压缩器的对象池
|
||||
},
|
||||
compress.EncodingDeflate: {
|
||||
Level: -1, // Deflate默认压缩比
|
||||
PoolEnabled: false, // Deflate不启用对象池
|
||||
},
|
||||
compress.EncodingZstd: {
|
||||
Level: int(zstd.SpeedBestCompression), // Zstandard最佳压缩比
|
||||
PoolEnabled: true, // 启用Zstandard压缩器的对象池
|
||||
},
|
||||
},
|
||||
|
||||
// MinContentLength: 响应内容达到此字节数才进行压缩 (例如 1KB)
|
||||
MinContentLength: 512,
|
||||
|
||||
// CompressibleTypes: 只有响应的 Content-Type 匹配此列表中的MIME类型前缀才进行压缩
|
||||
CompressibleTypes: compress.DefaultCompressibleTypes,
|
||||
|
||||
// EncodingPriority: 当客户端接受多种支持的压缩算法时,服务器选择的优先级顺序
|
||||
EncodingPriority: []string{
|
||||
compress.EncodingZstd,
|
||||
compress.EncodingGzip,
|
||||
compress.EncodingDeflate,
|
||||
},
|
||||
}))
|
||||
|
||||
store := cookie.NewStore(sessionKey)
|
||||
store.Options(sessions.Options{
|
||||
Path: "/",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue