This commit is contained in:
Kasper Juul Hermansen 2022-11-05 23:16:20 +01:00
parent ea93d6de45
commit d01dff5774
Signed by: kjuulh
GPG Key ID: 0F95C140730F2F23
2 changed files with 17 additions and 17 deletions

View File

@ -21,11 +21,11 @@ func (pc *PluginClient) Do(ctx context.Context, commandName string, args map[str
CommandName: commandName, CommandName: commandName,
Args: args, Args: args,
} }
doReq, err := json.Marshal(req) //doReq, err := json.Marshal(req)
if err != nil { //if err != nil {
return err // return err
} //}
err = pc.client.Call("Plugin.Do", doReq, new(any)) err := pc.client.Call("Plugin.Do", req, new(any))
if err != nil { if err != nil {
return err return err
} }

View File

@ -3,27 +3,27 @@ package register
import ( import (
"context" "context"
"encoding/json" "encoding/json"
"errors"
) )
type PluginServer struct { type PluginServer struct {
Impl Plugin Impl Plugin
} }
func (ps *PluginServer) Do(args any, resp *string) error { func (ps *PluginServer) Do(args *DoRequest, resp *string) error {
rawReq, ok := args.(string) //rawReq, ok := args.(string)
if !ok { //if !ok {
return errors.New("args is not a string") // return errors.New("args is not a string")
} //}
var doReq DoRequest //var doReq DoRequest
if err := json.Unmarshal([]byte(rawReq), &doReq); err != nil { //if err := json.Unmarshal([]byte(rawReq), &doReq); err != nil {
return err // return err
} //}
if err := ps.Impl.Do(context.Background(), doReq.CommandName, doReq.Args); err != nil { if err := ps.Impl.Do(context.Background(), args.CommandName, args.Args); err != nil {
return err return err
} }
*resp = ""
return nil return nil
} }