Skip to content

Commit

Permalink
Merge pull request #234 from typeless/master
Browse files Browse the repository at this point in the history
Less strict about message type of JSON payloads
  • Loading branch information
nhooyr committed May 5, 2020
2 parents c6e32e1 + 86e98b3 commit 1f37f5d
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions wsjson/wsjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 1f37f5d

Please sign in to comment.