mirror of
https://github.com/superseriousbusiness/gotosocial
synced 2025-06-05 21:59:39 +02:00
[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:
@@ -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,
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user