From 58d02340031ad43b378d04501ba43e8a69819902 Mon Sep 17 00:00:00 2001 From: ExplodingDragon Date: Fri, 21 Nov 2025 00:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86=E5=86=85=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/core/meta.go | 2 +- pkg/filters/common.go | 2 +- pkg/filters/goja/goja.go | 1 + pkg/providers/cache.go | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pkg/core/meta.go b/pkg/core/meta.go index 56a08c7..ccc9657 100644 --- a/pkg/core/meta.go +++ b/pkg/core/meta.go @@ -48,7 +48,7 @@ func NewEmptyPageMetaContent() *PageMetaContent { Filters: []Filter{ { Path: "**", - Type: "_404_", + Type: "404", Params: map[string]any{}, }, { // 默认阻塞 diff --git a/pkg/filters/common.go b/pkg/filters/common.go index a560efb..dcb2eb1 100644 --- a/pkg/filters/common.go +++ b/pkg/filters/common.go @@ -18,7 +18,7 @@ func DefaultFilters(config map[string]map[string]any) (map[string]core.FilterIns "redirect": FilterInstRedirect, "direct": FilterInstDirect, //"reverse_proxy": FilterInstProxy, - "_404_": FilterInstDefaultNotFound, + "404": FilterInstDefaultNotFound, "failback": FilterInstFailback, "template": FilterInstTemplate, "js": goja.FilterInstGoJa, diff --git a/pkg/filters/goja/goja.go b/pkg/filters/goja/goja.go index 77b2818..75edbcd 100644 --- a/pkg/filters/goja/goja.go +++ b/pkg/filters/goja/goja.go @@ -16,6 +16,7 @@ import ( "gopkg.d7z.net/gitea-pages/pkg/core" ) +// todo: 新增超时配置 func FilterInstGoJa(gl core.Params) (core.FilterInstance, error) { var global struct { Timeout time.Duration `json:"timeout"` diff --git a/pkg/providers/cache.go b/pkg/providers/cache.go index 068cf4e..b5d86ae 100644 --- a/pkg/providers/cache.go +++ b/pkg/providers/cache.go @@ -102,7 +102,7 @@ func (c *ProviderCache) Open(ctx context.Context, owner, repo, commit, path stri return nil, os.ErrNotExist } else if lastCache != nil { h := lastCache.Metadata - if h["_404_"] == "true" { + if h["404"] == "true" { return nil, os.ErrNotExist } respHeader := make(http.Header) @@ -133,7 +133,7 @@ func (c *ProviderCache) Open(ctx context.Context, owner, repo, commit, path stri // 当上游返回错误时,缓存404结果 if errors.Is(err, os.ErrNotExist) { if err = c.cacheBlob.Put(ctx, key, map[string]string{ - "_404_": "true", + "404": "true", }, bytes.NewBuffer(nil), time.Hour); err != nil { zap.L().Warn("缓存404失败", zap.Error(err)) } @@ -143,7 +143,7 @@ func (c *ProviderCache) Open(ctx context.Context, owner, repo, commit, path stri if open.StatusCode == http.StatusNotFound { // 缓存404路由 if err = c.cacheBlob.Put(ctx, key, map[string]string{ - "_404_": "true", + "404": "true", }, bytes.NewBuffer(nil), time.Hour); err != nil { zap.L().Warn("缓存404失败", zap.Error(err)) }