[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

@@ -20,6 +20,7 @@ package streaming
import (
"net/http"
"time"
"github.com/superseriousbusiness/gotosocial/internal/api"
"github.com/superseriousbusiness/gotosocial/internal/processing"
@@ -35,17 +36,29 @@ const (
// AccessTokenQueryKey is the query key for an oauth access token that should be passed in streaming requests.
AccessTokenQueryKey = "access_token"
// AccessTokenHeader is the header for an oauth access token that can be passed in streaming requests instead of AccessTokenQueryKey
//nolint:gosec
AccessTokenHeader = "Sec-Websocket-Protocol"
)
// Module implements the api.ClientModule interface for everything related to streaming
type Module struct {
processor processing.Processor
processor processing.Processor
tickDuration time.Duration
}
// New returns a new streaming module
func New(processor processing.Processor) api.ClientModule {
return &Module{
processor: processor,
processor: processor,
tickDuration: 30 * time.Second,
}
}
func NewWithTickDuration(processor processing.Processor, tickDuration time.Duration) api.ClientModule {
return &Module{
processor: processor,
tickDuration: tickDuration,
}
}