From 8bf7379170ab83764fda7c167940316c92fd39d0 Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Tue, 20 Dec 2022 21:27:07 -0500 Subject: [PATCH] don't use map structure if we're already a map --- pkg/wsapi/api.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkg/wsapi/api.go b/pkg/wsapi/api.go index 9615258..2277257 100644 --- a/pkg/wsapi/api.go +++ b/pkg/wsapi/api.go @@ -195,14 +195,16 @@ func (ws *cmdHandler) handleMsg(r io.Reader) error { } nd := newData(cmd) - err = mapstructure.Decode(&msgMap, &nd) - if err != nil { - ws.writeError(id, Error{ - Code: "invalid_format", - Message: err.Error(), - }) + if _, ok := nd.(map[string]interface{}); !ok { + err := mapstructure.Decode(&msgMap, &nd) + if err != nil { + ws.writeError(id, Error{ + Code: "invalid_format", + Message: err.Error(), + }) - return nil + return nil + } } return hand(ws, id, cmd, nd)