diff --git a/contrib/extension/subscription/engine.go b/contrib/extension/subscription/engine.go index 184e06175d231f31fa0e03950d9827a43936af02..e4ba9a25946bff45723bf187749b7adbe21f36c7 100644 --- a/contrib/extension/subscription/engine.go +++ b/contrib/extension/subscription/engine.go @@ -2,6 +2,7 @@ package subscription import ( "context" + "encoding/json" "strings" "sync" @@ -61,14 +62,16 @@ func (e *Engine) Middleware() func(jsonrpc.Handler) jsonrpc.Handler { h.ServeRPC(w, r) case strings.HasSuffix(r.Method, serviceMethodSeparator+unsubscribeMethodSuffix): // read the subscription id to close - var subid SubID - err := r.ParamArray(subid) + resp := []SubID{} + err := json.Unmarshal(r.Params, &resp) if err != nil { w.Send(false, err) return } - // close that sub - w.Send(e.closeSub(subid)) + // close subs + if len(resp) > 0 { + w.Send(e.closeSub(resp[0])) + } default: h.ServeRPC(w, r) } diff --git a/pkg/jsonrpc/reqresp.go b/pkg/jsonrpc/reqresp.go index ebff64f8ef9de09649d1186568044360615740b8..5a4d12f4a9c09f677095c73a3237e1dda94a7676 100644 --- a/pkg/jsonrpc/reqresp.go +++ b/pkg/jsonrpc/reqresp.go @@ -71,25 +71,6 @@ func NewRequest(ctx context.Context, id *ID, method string, params any) (r *Requ return NewRawRequest(ctx, id, method, raw), nil } -func (r *Request) ParamArray(a ...any) error { - var params []json.RawMessage - err := json.Unmarshal(r.Params, ¶ms) - if err != nil { - return err - } - for idx, v := range params { - if len(v) > idx { - err := json.Unmarshal(v, &a[idx]) - if err != nil { - return err - } - } else { - break - } - } - return nil -} - func (r *Request) Context() context.Context { return r.ctx }