更新 middleware
This commit is contained in:
@@ -19,8 +19,8 @@ type FilterContext struct {
|
||||
*PageContent
|
||||
*PageVFS
|
||||
Cache *tools.TTLCache
|
||||
OrgDB kv.CursorPagedKV
|
||||
RepoDB kv.CursorPagedKV
|
||||
OrgDB kv.KV
|
||||
RepoDB kv.KV
|
||||
Event subscribe.Subscriber
|
||||
|
||||
Kill func()
|
||||
|
||||
@@ -21,12 +21,12 @@ func KVInject(ctx core.FilterContext, jsCtx *goja.Runtime) error {
|
||||
})
|
||||
}
|
||||
|
||||
func kvResult(db kv.CursorPagedKV) func(ctx core.FilterContext, jsCtx *goja.Runtime, group ...string) (goja.Value, error) {
|
||||
func kvResult(db kv.KV) func(ctx core.FilterContext, jsCtx *goja.Runtime, group ...string) (goja.Value, error) {
|
||||
return func(ctx core.FilterContext, jsCtx *goja.Runtime, group ...string) (goja.Value, error) {
|
||||
if len(group) == 0 {
|
||||
return goja.Undefined(), errors.New("invalid group")
|
||||
}
|
||||
db := db.Child(group...).(kv.CursorPagedKV)
|
||||
db := db.Child(group...)
|
||||
return jsCtx.ToValue(map[string]interface{}{
|
||||
"get": func(key string) (goja.Value, error) {
|
||||
get, err := db.Get(ctx, key)
|
||||
|
||||
@@ -28,7 +28,7 @@ var portExp = regexp.MustCompile(`:\d+$`)
|
||||
type Server struct {
|
||||
backend core.Backend
|
||||
meta *core.PageDomain
|
||||
db kv.CursorPagedKV
|
||||
db kv.KV
|
||||
filterMgr map[string]core.FilterInstance
|
||||
|
||||
globCache *lru.Cache[string, glob.Glob]
|
||||
@@ -94,7 +94,7 @@ func WithFilterConfig(config map[string]map[string]any) ServerOption {
|
||||
func NewPageServer(
|
||||
backend core.Backend,
|
||||
domain string,
|
||||
db kv.CursorPagedKV,
|
||||
db kv.KV,
|
||||
opts ...ServerOption,
|
||||
) (*Server, error) {
|
||||
cfg := &serverConfig{
|
||||
@@ -197,8 +197,8 @@ func (s *Server) Serve(writer *utils.WrittenResponseWriter, request *http.Reques
|
||||
Context: cancelCtx,
|
||||
PageVFS: core.NewPageVFS(s.backend, meta.Owner, meta.Repo, meta.CommitID),
|
||||
Cache: tools.NewTTLCache(s.cacheBlob.Child("filter", meta.Owner, meta.Repo, meta.CommitID), s.cacheBlobTTL),
|
||||
OrgDB: s.db.Child("org", meta.Owner).(kv.CursorPagedKV),
|
||||
RepoDB: s.db.Child("repo", meta.Owner, meta.Repo).(kv.CursorPagedKV),
|
||||
OrgDB: s.db.Child("org", meta.Owner),
|
||||
RepoDB: s.db.Child("repo", meta.Owner, meta.Repo),
|
||||
Event: s.event.Child("domain", meta.Owner, meta.Repo),
|
||||
|
||||
Kill: cancelFunc,
|
||||
|
||||
Reference in New Issue
Block a user