don't use map structure if we're already a map

This commit is contained in:
Daniel Ponte 2022-12-20 21:27:07 -05:00
parent 2ddac95715
commit 8bf7379170

View file

@ -195,14 +195,16 @@ func (ws *cmdHandler) handleMsg(r io.Reader) error {
} }
nd := newData(cmd) nd := newData(cmd)
err = mapstructure.Decode(&msgMap, &nd) if _, ok := nd.(map[string]interface{}); !ok {
if err != nil { err := mapstructure.Decode(&msgMap, &nd)
ws.writeError(id, Error{ if err != nil {
Code: "invalid_format", ws.writeError(id, Error{
Message: err.Error(), Code: "invalid_format",
}) Message: err.Error(),
})
return nil return nil
}
} }
return hand(ws, id, cmd, nd) return hand(ws, id, cmd, nd)