清理内容
This commit is contained in:
@@ -48,7 +48,7 @@ func NewEmptyPageMetaContent() *PageMetaContent {
|
|||||||
Filters: []Filter{
|
Filters: []Filter{
|
||||||
{
|
{
|
||||||
Path: "**",
|
Path: "**",
|
||||||
Type: "_404_",
|
Type: "404",
|
||||||
Params: map[string]any{},
|
Params: map[string]any{},
|
||||||
},
|
},
|
||||||
{ // 默认阻塞
|
{ // 默认阻塞
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ func DefaultFilters(config map[string]map[string]any) (map[string]core.FilterIns
|
|||||||
"redirect": FilterInstRedirect,
|
"redirect": FilterInstRedirect,
|
||||||
"direct": FilterInstDirect,
|
"direct": FilterInstDirect,
|
||||||
//"reverse_proxy": FilterInstProxy,
|
//"reverse_proxy": FilterInstProxy,
|
||||||
"_404_": FilterInstDefaultNotFound,
|
"404": FilterInstDefaultNotFound,
|
||||||
"failback": FilterInstFailback,
|
"failback": FilterInstFailback,
|
||||||
"template": FilterInstTemplate,
|
"template": FilterInstTemplate,
|
||||||
"js": goja.FilterInstGoJa,
|
"js": goja.FilterInstGoJa,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import (
|
|||||||
"gopkg.d7z.net/gitea-pages/pkg/core"
|
"gopkg.d7z.net/gitea-pages/pkg/core"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// todo: 新增超时配置
|
||||||
func FilterInstGoJa(gl core.Params) (core.FilterInstance, error) {
|
func FilterInstGoJa(gl core.Params) (core.FilterInstance, error) {
|
||||||
var global struct {
|
var global struct {
|
||||||
Timeout time.Duration `json:"timeout"`
|
Timeout time.Duration `json:"timeout"`
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ func (c *ProviderCache) Open(ctx context.Context, owner, repo, commit, path stri
|
|||||||
return nil, os.ErrNotExist
|
return nil, os.ErrNotExist
|
||||||
} else if lastCache != nil {
|
} else if lastCache != nil {
|
||||||
h := lastCache.Metadata
|
h := lastCache.Metadata
|
||||||
if h["_404_"] == "true" {
|
if h["404"] == "true" {
|
||||||
return nil, os.ErrNotExist
|
return nil, os.ErrNotExist
|
||||||
}
|
}
|
||||||
respHeader := make(http.Header)
|
respHeader := make(http.Header)
|
||||||
@@ -133,7 +133,7 @@ func (c *ProviderCache) Open(ctx context.Context, owner, repo, commit, path stri
|
|||||||
// 当上游返回错误时,缓存404结果
|
// 当上游返回错误时,缓存404结果
|
||||||
if errors.Is(err, os.ErrNotExist) {
|
if errors.Is(err, os.ErrNotExist) {
|
||||||
if err = c.cacheBlob.Put(ctx, key, map[string]string{
|
if err = c.cacheBlob.Put(ctx, key, map[string]string{
|
||||||
"_404_": "true",
|
"404": "true",
|
||||||
}, bytes.NewBuffer(nil), time.Hour); err != nil {
|
}, bytes.NewBuffer(nil), time.Hour); err != nil {
|
||||||
zap.L().Warn("缓存404失败", zap.Error(err))
|
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 {
|
if open.StatusCode == http.StatusNotFound {
|
||||||
// 缓存404路由
|
// 缓存404路由
|
||||||
if err = c.cacheBlob.Put(ctx, key, map[string]string{
|
if err = c.cacheBlob.Put(ctx, key, map[string]string{
|
||||||
"_404_": "true",
|
"404": "true",
|
||||||
}, bytes.NewBuffer(nil), time.Hour); err != nil {
|
}, bytes.NewBuffer(nil), time.Hour); err != nil {
|
||||||
zap.L().Warn("缓存404失败", zap.Error(err))
|
zap.L().Warn("缓存404失败", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user