mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-11-17 22:30:25 +08:00
实现缓存策略的部分功能
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package cache
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/actionutils"
|
||||
"github.com/TeaOSLab/EdgeAdmin/internal/web/actions/default/servers/components/cache/cacheutils"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"net/http"
|
||||
"reflect"
|
||||
)
|
||||
|
||||
type Helper struct {
|
||||
@@ -12,11 +15,23 @@ func NewHelper() *Helper {
|
||||
return &Helper{}
|
||||
}
|
||||
|
||||
func (this *Helper) BeforeAction(action *actions.ActionObject) {
|
||||
func (this *Helper) BeforeAction(actionPtr actions.ActionWrapper) {
|
||||
action := actionPtr.Object()
|
||||
if action.Request.Method != http.MethodGet {
|
||||
return
|
||||
}
|
||||
|
||||
action.Data["mainTab"] = "component"
|
||||
action.Data["secondMenuItem"] = "cache"
|
||||
|
||||
cachePolicyId := action.ParamInt64("cachePolicyId")
|
||||
action.Data["cachePolicyId"] = cachePolicyId
|
||||
|
||||
parentActionValue := reflect.ValueOf(actionPtr).Elem().FieldByName("ParentAction")
|
||||
if parentActionValue.IsValid() {
|
||||
parentAction, isOk := parentActionValue.Interface().(actionutils.ParentAction)
|
||||
if isOk {
|
||||
action.Data["cachePolicyName"] = cacheutils.FindCachePolicyNameWithoutError(&parentAction, cachePolicyId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user