diff options
| author | Shulhan <ms@kilabit.info> | 2021-04-09 19:40:11 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-04-09 19:40:11 +0700 |
| commit | eb2dbaf27910f968f21c178929d056b64e9f242c (patch) | |
| tree | 9222d888921f9bdb2c18e3060e180cb17b2bbb98 | |
| parent | 1eb00b560734683315dabbf906123aae8358e9bf (diff) | |
| download | gorankusu-eb2dbaf27910f968f21c178929d056b64e9f242c.tar.xz | |
all: change the WebSocket run return type to interface{}
Instead of []byte, the call to Run on WebSocketTarget can return anything,
since we will wrap it inside the EndpointRequest.Data later.
| -rw-r--r-- | example/example.go | 6 | ||||
| -rw-r--r-- | websocket_target.go | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/example/example.go b/example/example.go index cbdb840..6cc6e78 100644 --- a/example/example.go +++ b/example/example.go @@ -366,13 +366,13 @@ func (ex *Example) handleWSExampleGet(ctx context.Context, req *websocket.Reques return res } -func (ex *Example) runWebSocketGet(rr *trunks.RunRequest) (resbody []byte, err error) { +func (ex *Example) runWebSocketGet(rr *trunks.RunRequest) (res interface{}, err error) { var wg sync.WaitGroup wsc := &websocket.Client{ Endpoint: "ws://" + websocketAddress, HandleText: func(cl *websocket.Client, frame *websocket.Frame) error { - resbody = frame.Payload() + res = frame.Payload() wg.Done() return nil }, @@ -409,5 +409,5 @@ func (ex *Example) runWebSocketGet(rr *trunks.RunRequest) (resbody []byte, err e _ = wsc.Close() - return resbody, err + return res, nil } diff --git a/websocket_target.go b/websocket_target.go index 4e17ab9..88bab36 100644 --- a/websocket_target.go +++ b/websocket_target.go @@ -10,7 +10,7 @@ import "fmt" // WebSocketRunHandler define a function type that will be called to run the // WebSocket target. // -type WebSocketRunHandler func(rr *RunRequest) ([]byte, error) +type WebSocketRunHandler func(rr *RunRequest) (interface{}, error) // // WebSocketTarget define the target to test WebSocket service. |
