4.0.0-beta.0

This commit is contained in:
wjqserver 2025-06-16 08:28:02 +08:00
parent 91c3ad7fd8
commit a4d324a361
38 changed files with 497 additions and 1428 deletions

View file

@ -1,17 +1,15 @@
package nocache
import (
"context"
"github.com/cloudwego/hertz/pkg/app"
"github.com/infinite-iroha/touka"
)
func NoCacheMiddleware() app.HandlerFunc {
return func(ctx context.Context, c *app.RequestContext) {
func NoCacheMiddleware() touka.HandlerFunc {
return func(c *touka.Context) {
// 设置禁止缓存的响应头
c.Response.Header.Set("Cache-Control", "no-store, no-cache, must-revalidate")
c.Response.Header.Set("Pragma", "no-cache")
c.Response.Header.Set("Expires", "0")
c.Next(ctx) // 继续处理请求
c.SetHeader("Cache-Control", "no-store, no-cache, must-revalidate")
c.SetHeader("Pragma", "no-cache")
c.SetHeader("Expires", "0")
c.Next() // 继续处理请求
}
}