From 86e98b36a2a04323711d9d94a419c682cd715795 Mon Sep 17 00:00:00 2001
From: Mura Li <mura_li@castech.com.tw>
Date: Tue, 5 May 2020 11:37:28 +0800
Subject: [PATCH] Less strict about message type of JSON payloads

---
 wsjson/wsjson.go | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/wsjson/wsjson.go b/wsjson/wsjson.go
index 99996a6..2000a77 100644
--- a/wsjson/wsjson.go
+++ b/wsjson/wsjson.go
@@ -20,16 +20,11 @@ func Read(ctx context.Context, c *websocket.Conn, v interface{}) error {
 func read(ctx context.Context, c *websocket.Conn, v interface{}) (err error) {
 	defer errd.Wrap(&err, "failed to read JSON message")
 
-	typ, r, err := c.Reader(ctx)
+	_, r, err := c.Reader(ctx)
 	if err != nil {
 		return err
 	}
 
-	if typ != websocket.MessageText {
-		c.Close(websocket.StatusUnsupportedData, "expected text message")
-		return fmt.Errorf("expected text message for JSON but got: %v", typ)
-	}
-
 	b := bpool.Get()
 	defer bpool.Put(b)
 
-- 
GitLab