Documentation
¶
Index ¶
- Constants
- Variables
- type Config
- func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
- func (m *Config) CloneVT() *Config
- func (this *Config) EqualMessageVT(thatMsg any) bool
- func (this *Config) EqualVT(that *Config) bool
- func (c *Config) EqualsConfig(c2 config.Config) bool
- func (c *Config) GetConfigID() string
- func (c *Config) GetDebugVals() config.DebugValues
- func (x *Config) GetDialers() map[string]*dialer.DialerOpts
- func (x *Config) GetHttpPatterns() []string
- func (x *Config) GetPeerHttpPatterns() []string
- func (x *Config) GetQuic() *quic.Opts
- func (x *Config) GetTransportPeerId() string
- func (x *Config) MarshalJSON() ([]byte, error)
- func (x *Config) MarshalProtoJSON(s *json.MarshalState)
- func (x *Config) MarshalProtoText() string
- func (m *Config) MarshalToSizedBufferVT(dAtA []byte) (int, error)
- func (m *Config) MarshalToVT(dAtA []byte) (int, error)
- func (m *Config) MarshalVT() (dAtA []byte, err error)
- func (c *Config) ParseTransportPeerID() (peer.ID, error)
- func (*Config) ProtoMessage()
- func (x *Config) Reset()
- func (c *Config) SetTransportPeerId(peerID string)
- func (m *Config) SizeVT() (n int)
- func (x *Config) String() string
- func (x *Config) UnmarshalJSON(b []byte) error
- func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
- func (m *Config) UnmarshalVT(dAtA []byte) error
- func (c *Config) Validate() error
- type Config_DialersEntry
- func (x *Config_DialersEntry) GetKey() string
- func (x *Config_DialersEntry) GetValue() *dialer.DialerOpts
- func (x *Config_DialersEntry) MarshalJSON() ([]byte, error)
- func (x *Config_DialersEntry) MarshalProtoJSON(s *json.MarshalState)
- func (x *Config_DialersEntry) MarshalProtoText() string
- func (*Config_DialersEntry) ProtoMessage()
- func (x *Config_DialersEntry) Reset()
- func (x *Config_DialersEntry) String() string
- func (x *Config_DialersEntry) UnmarshalJSON(b []byte) error
- func (x *Config_DialersEntry) UnmarshalProtoJSON(s *json.UnmarshalState)
- type Factory
- func (t *Factory) Construct(ctx context.Context, conf config.Config, opts controller.ConstructOpts) (controller.Controller, error)
- func (t *Factory) ConstructConfig() config.Config
- func (t *Factory) GetConfigID() string
- func (t *Factory) GetControllerID() string
- func (t *Factory) GetVersion() semver.Version
- type WebSocketHttp
- func (t *WebSocketHttp) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)
- func (t *WebSocketHttp) ResolveLookupHTTPHandler(ctx context.Context, dir bifrost_http.LookupHTTPHandler) ([]directive.Resolver, error)
- func (t *WebSocketHttp) ServePeerHTTP(rw http.ResponseWriter, req *http.Request)
- func (t *WebSocketHttp) ServeWebSocketHTTP(rw http.ResponseWriter, req *http.Request)
Constants ¶
const ConfigID = ControllerID
ConfigID is the string used to identify this config object.
const ControllerID = "bifrost/websocket/http"
ControllerID is the WebSocket HTTP handler controller ID.
Variables ¶
var Version = semver.MustParse("0.0.1")
Version is the version of the implementation.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct { // TransportPeerID sets the peer ID to attach the transport to. // If unset, attaches to any running peer with a private key. TransportPeerId string `protobuf:"bytes,1,opt,name=transport_peer_id,json=transportPeerId,proto3" json:"transportPeerId,omitempty"` // HttpPatterns is the list of patterns to listen on. // Example: ["GET example.com/my/ws", "GET /other/path"] HttpPatterns []string `protobuf:"bytes,2,rep,name=http_patterns,json=httpPatterns,proto3" json:"httpPatterns,omitempty"` // PeerHttpPatterns is the list of patterns to serve the peer ID on. // Example: ["GET example.com/my/ws/peer-id", "GET /other/path/peer-id"] PeerHttpPatterns []string `protobuf:"bytes,3,rep,name=peer_http_patterns,json=peerHttpPatterns,proto3" json:"peerHttpPatterns,omitempty"` // Quic contains the quic protocol options. // // The WebSocket transport always disables FEC and several other UDP-centric // features which are unnecessary due to the "reliable" nature of WebSockets. Quic *quic.Opts `protobuf:"bytes,4,opt,name=quic,proto3" json:"quic,omitempty"` // Dialers maps peer IDs to dialers. Dialers map[string]*dialer.DialerOpts `` /* 155-byte string literal not displayed */ // contains filtered or unexported fields }
Config is the configuration for the Websocket HTTP handler transport.
Listen for incoming connections with bifrost/http/listener This controller resolves LookupHTTPHandler directives filtering by ServeMux patterns. Example: ["GET example.com/my/ws", "GET /other/path"]
func (*Config) CloneMessageVT ¶
func (m *Config) CloneMessageVT() protobuf_go_lite.CloneMessage
func (*Config) EqualMessageVT ¶
func (*Config) EqualsConfig ¶
EqualsConfig checks if the other config is equal.
func (*Config) GetConfigID ¶
GetConfigID returns the unique string for this configuration type. This string is stored with the encoded config.
func (*Config) GetDebugVals ¶
func (c *Config) GetDebugVals() config.DebugValues
GetDebugVals returns the directive arguments as key/value pairs. This should be something like param1="test", param2="test". This is not necessarily unique, and is primarily intended for display.
func (*Config) GetDialers ¶
func (x *Config) GetDialers() map[string]*dialer.DialerOpts
func (*Config) GetHttpPatterns ¶
func (*Config) GetPeerHttpPatterns ¶
func (*Config) GetTransportPeerId ¶
func (*Config) MarshalJSON ¶
MarshalJSON marshals the Config to JSON.
func (*Config) MarshalProtoJSON ¶
func (x *Config) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the Config message to JSON.
func (*Config) MarshalProtoText ¶
func (*Config) MarshalToSizedBufferVT ¶
func (*Config) ParseTransportPeerID ¶
ParseTransportPeerID parses the node peer ID if it is not empty.
func (*Config) ProtoMessage ¶
func (*Config) ProtoMessage()
func (*Config) SetTransportPeerId ¶
SetTransportPeerId sets the node peer ID field.
func (*Config) UnmarshalJSON ¶
UnmarshalJSON unmarshals the Config from JSON.
func (*Config) UnmarshalProtoJSON ¶
func (x *Config) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the Config message from JSON.
func (*Config) UnmarshalVT ¶
type Config_DialersEntry ¶
type Config_DialersEntry struct { Key string `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` Value *dialer.DialerOpts `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` // contains filtered or unexported fields }
func (*Config_DialersEntry) GetKey ¶
func (x *Config_DialersEntry) GetKey() string
func (*Config_DialersEntry) GetValue ¶
func (x *Config_DialersEntry) GetValue() *dialer.DialerOpts
func (*Config_DialersEntry) MarshalJSON ¶
func (x *Config_DialersEntry) MarshalJSON() ([]byte, error)
MarshalJSON marshals the Config_DialersEntry to JSON.
func (*Config_DialersEntry) MarshalProtoJSON ¶
func (x *Config_DialersEntry) MarshalProtoJSON(s *json.MarshalState)
MarshalProtoJSON marshals the Config_DialersEntry message to JSON.
func (*Config_DialersEntry) MarshalProtoText ¶
func (x *Config_DialersEntry) MarshalProtoText() string
func (*Config_DialersEntry) ProtoMessage ¶
func (*Config_DialersEntry) ProtoMessage()
func (*Config_DialersEntry) Reset ¶
func (x *Config_DialersEntry) Reset()
func (*Config_DialersEntry) String ¶
func (x *Config_DialersEntry) String() string
func (*Config_DialersEntry) UnmarshalJSON ¶
func (x *Config_DialersEntry) UnmarshalJSON(b []byte) error
UnmarshalJSON unmarshals the Config_DialersEntry from JSON.
func (*Config_DialersEntry) UnmarshalProtoJSON ¶
func (x *Config_DialersEntry) UnmarshalProtoJSON(s *json.UnmarshalState)
UnmarshalProtoJSON unmarshals the Config_DialersEntry message from JSON.
type Factory ¶
type Factory struct {
// contains filtered or unexported fields
}
Factory constructs a WebSocket transport.
func (*Factory) Construct ¶
func (t *Factory) Construct( ctx context.Context, conf config.Config, opts controller.ConstructOpts, ) (controller.Controller, error)
Construct constructs the associated controller given configuration.
func (*Factory) ConstructConfig ¶
ConstructConfig constructs an instance of the controller configuration.
func (*Factory) GetConfigID ¶
GetConfigID returns the configuration ID for the controller.
func (*Factory) GetControllerID ¶
GetControllerID returns the unique ID for the controller.
func (*Factory) GetVersion ¶
func (t *Factory) GetVersion() semver.Version
GetVersion returns the version of this controller.
type WebSocketHttp ¶
type WebSocketHttp struct { // Controller is the transport controller *transport_controller.Controller // contains filtered or unexported fields }
NewWebSocketHttp builds a new WebSocket http handler controller.
func NewWebSocketHttp ¶
NewWebSocketHttp builds a new WebSocket http handler controller.
func (*WebSocketHttp) HandleDirective ¶
func (t *WebSocketHttp) HandleDirective(ctx context.Context, di directive.Instance) ([]directive.Resolver, error)
HandleDirective asks if the handler can resolve the directive. If it can, it returns resolver(s). If not, returns nil. It is safe to add a reference to the directive during this call. The passed context is canceled when the directive instance expires. NOTE: the passed context is not canceled when the handler is removed.
func (*WebSocketHttp) ResolveLookupHTTPHandler ¶
func (t *WebSocketHttp) ResolveLookupHTTPHandler(ctx context.Context, dir bifrost_http.LookupHTTPHandler) ([]directive.Resolver, error)
ResolveLookupHTTPHandler resolves the LookupHTTPHandler directive conditionally. Returns nil, nil if no handlers matched.
func (*WebSocketHttp) ServePeerHTTP ¶
func (t *WebSocketHttp) ServePeerHTTP(rw http.ResponseWriter, req *http.Request)
ServePeerHTTP serves the peer ID as a string on the HTTP response.
func (*WebSocketHttp) ServeWebSocketHTTP ¶
func (t *WebSocketHttp) ServeWebSocketHTTP(rw http.ResponseWriter, req *http.Request)
ServeWebSocketHTTP serves the WebSocket on the HTTP response.