[feature] support Sec-Websocket-Protocol in streaming API (#1254)

* [feature] support Sec-Websocket-Protocol in streaming API

* Fix lint problem

* Update based on reviews
This commit is contained in:
Matthew Phillips
2022-12-14 04:56:42 -05:00
committed by GitHub
parent 69dd5fed2c
commit d10388cc28
3 changed files with 255 additions and 4 deletions

View File

@@ -131,7 +131,10 @@ func (m *Module) StreamGETHandler(c *gin.Context) {
accessToken := c.Query(AccessTokenQueryKey)
if accessToken == "" {
err := fmt.Errorf("no access token provided under query key %s", AccessTokenQueryKey)
accessToken = c.GetHeader(AccessTokenHeader)
}
if accessToken == "" {
err := fmt.Errorf("no access token provided under query key %s or under header %s", AccessTokenQueryKey, AccessTokenHeader)
api.ErrorHandler(c, gtserror.NewErrorUnauthorized(err, err.Error()), m.processor.InstanceGet)
return
}
@@ -171,7 +174,7 @@ func (m *Module) StreamGETHandler(c *gin.Context) {
close(stream.Hangup)
}()
streamTicker := time.NewTicker(30 * time.Second)
streamTicker := time.NewTicker(m.tickDuration)
// We want to stay in the loop as long as possible while the client is connected.
// The only thing that should break the loop is if the client leaves or the connection becomes unhealthy.