From da6f515078113700c425d2981abc5f2c90a95add Mon Sep 17 00:00:00 2001 From: blainepwnz Date: Sat, 3 Jun 2017 00:09:21 +0300 Subject: [PATCH] added subprotocols to server config (#652) Former-commit-id: c4793e7355d393bb479c69fc8f4f7ae65bc3668d --- adaptors/websocket/config.go | 4 ++++ adaptors/websocket/server.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/adaptors/websocket/config.go b/adaptors/websocket/config.go index 2d942ecb..62e843dc 100644 --- a/adaptors/websocket/config.go +++ b/adaptors/websocket/config.go @@ -77,6 +77,10 @@ type Config struct { // The request is an argument which you can use to generate the ID (from headers for example). // If empty then the ID is generated by DefaultIDGenerator: randomString(64) IDGenerator func(ctx *iris.Context) string + /** + List od subprotocols accepted by server + */ + Subprotocols []string } // Validate validates the configuration diff --git a/adaptors/websocket/server.go b/adaptors/websocket/server.go index 9a722df1..8604274f 100644 --- a/adaptors/websocket/server.go +++ b/adaptors/websocket/server.go @@ -184,7 +184,7 @@ func (s *server) Handler() iris.HandlerFunc { // build the upgrader once c := s.config - upgrader := websocket.Upgrader{ReadBufferSize: c.ReadBufferSize, WriteBufferSize: c.WriteBufferSize, Error: c.Error, CheckOrigin: c.CheckOrigin} + upgrader := websocket.Upgrader{ReadBufferSize: c.ReadBufferSize, WriteBufferSize: c.WriteBufferSize, Error: c.Error, CheckOrigin: c.CheckOrigin , Subprotocols:c.Subprotocols} return func(ctx *iris.Context) { // Upgrade upgrades the HTTP server connection to the WebSocket protocol. //