Documentation
¶
Index ¶
- Constants
- Variables
- func WriteError(resp http.ResponseWriter, err error)
- type Ack
- type AckRange
- type Bye
- type DataChannel
- func (*DataChannel) Descriptor() ([]byte, []int)deprecated
- func (x *DataChannel) GetHeartbeat() *DataChannelHeartbeat
- func (m *DataChannel) GetPayload() isDataChannel_Payload
- func (*DataChannel) ProtoMessage()
- func (x *DataChannel) ProtoReflect() protoreflect.Message
- func (x *DataChannel) Reset()
- func (x *DataChannel) String() string
- type DataChannelHeartbeat
- type DataChannel_Heartbeat
- type HTTPClient
- type ICECandidate
- func (*ICECandidate) Descriptor() ([]byte, []int)deprecated
- func (x *ICECandidate) GetCandidate() string
- func (x *ICECandidate) GetPassword() string
- func (x *ICECandidate) GetSdpMLineIndex() uint32
- func (x *ICECandidate) GetSdpMid() string
- func (x *ICECandidate) GetUsername() string
- func (*ICECandidate) ProtoMessage()
- func (x *ICECandidate) ProtoReflect() protoreflect.Message
- func (x *ICECandidate) Reset()
- func (x *ICECandidate) String() string
- type IceServer
- func (*IceServer) Descriptor() ([]byte, []int)deprecated
- func (x *IceServer) GetCredential() string
- func (x *IceServer) GetUrls() []string
- func (x *IceServer) GetUsername() string
- func (*IceServer) ProtoMessage()
- func (x *IceServer) ProtoReflect() protoreflect.Message
- func (x *IceServer) Reset()
- func (x *IceServer) String() string
- type Join
- type Message
- type MessageHeader
- func (*MessageHeader) Descriptor() ([]byte, []int)deprecated
- func (x *MessageHeader) GetConnId() uint32
- func (x *MessageHeader) GetGroupId() string
- func (x *MessageHeader) GetOtherConnId() uint32
- func (x *MessageHeader) GetOtherGroupId() string
- func (x *MessageHeader) GetOtherPeerId() string
- func (x *MessageHeader) GetPeerId() string
- func (x *MessageHeader) GetReliable() bool
- func (x *MessageHeader) GetSeqnum() uint32
- func (*MessageHeader) ProtoMessage()
- func (x *MessageHeader) ProtoReflect() protoreflect.Message
- func (x *MessageHeader) Reset()
- func (x *MessageHeader) String() string
- type MessagePayload
- func (*MessagePayload) Descriptor() ([]byte, []int)deprecated
- func (x *MessagePayload) GetAck() *Ack
- func (x *MessagePayload) GetBye() *Bye
- func (x *MessagePayload) GetJoin() *Join
- func (m *MessagePayload) GetPayloadType() isMessagePayload_PayloadType
- func (x *MessagePayload) GetSignal() *Signal
- func (*MessagePayload) ProtoMessage()
- func (x *MessagePayload) ProtoReflect() protoreflect.Message
- func (x *MessagePayload) Reset()
- func (x *MessagePayload) String() string
- type MessagePayload_Ack
- type MessagePayload_Bye
- type MessagePayload_Join
- type MessagePayload_Signal
- type PeerInfo
- type PrepareReq
- type PrepareResp
- type RecvReq
- type RecvResp
- type Sdp
- type SdpKind
- type SendReq
- type SendResp
- type Signal
- func (*Signal) Descriptor() ([]byte, []int)deprecated
- func (m *Signal) GetData() isSignal_Data
- func (x *Signal) GetGenerationCounter() uint32
- func (x *Signal) GetIceCandidate() *ICECandidate
- func (x *Signal) GetSdp() *Sdp
- func (*Signal) ProtoMessage()
- func (x *Signal) ProtoReflect() protoreflect.Message
- func (x *Signal) Reset()
- func (x *Signal) String() string
- type Signal_IceCandidate
- type Signal_Sdp
- type Tunnel
- type TwirpServer
Constants ¶
const TunnelPathPrefix = "/twirp/service.rpc.v1.Tunnel/"
TunnelPathPrefix is a convenience constant that may identify URL paths. Should be used with caution, it only matches routes generated by Twirp Go clients, with the default "/twirp" prefix and default CamelCase service and method names. More info: https://twitchtv.github.io/twirp/docs/routing.html
Variables ¶
var ( SdpKind_name = map[int32]string{ 0: "SDP_KIND_UNSPECIFIED", 1: "SDP_KIND_OFFER", 2: "SDP_KIND_ANSWER", 3: "SDP_KIND_PRANSWER", 4: "SDP_KIND_ROLLBACK", } SdpKind_value = map[string]int32{ "SDP_KIND_UNSPECIFIED": 0, "SDP_KIND_OFFER": 1, "SDP_KIND_ANSWER": 2, "SDP_KIND_PRANSWER": 3, "SDP_KIND_ROLLBACK": 4, } )
Enum value maps for SdpKind.
var File_tunnel_proto protoreflect.FileDescriptor
Functions ¶
func WriteError ¶
func WriteError(resp http.ResponseWriter, err error)
WriteError writes an HTTP response with a valid Twirp error format (code, msg, meta). Useful outside of the Twirp server (e.g. http middleware), but does not trigger hooks. If err is not a twirp.Error, it will get wrapped with twirp.InternalErrorWith(err)
Types ¶
type Ack ¶
type Ack struct { AckRanges []*AckRange `protobuf:"bytes,1,rep,name=ack_ranges,json=ackRanges,proto3" json:"ack_ranges,omitempty"` // contains filtered or unexported fields }
func (*Ack) Descriptor
deprecated
func (*Ack) GetAckRanges ¶
func (*Ack) ProtoMessage ¶
func (*Ack) ProtoMessage()
func (*Ack) ProtoReflect ¶
func (x *Ack) ProtoReflect() protoreflect.Message
type AckRange ¶
type AckRange struct { SeqnumStart uint32 `protobuf:"varint,1,opt,name=seqnum_start,json=seqnumStart,proto3" json:"seqnum_start,omitempty"` SeqnumEnd uint32 `protobuf:"varint,2,opt,name=seqnum_end,json=seqnumEnd,proto3" json:"seqnum_end,omitempty"` // contains filtered or unexported fields }
func (*AckRange) Descriptor
deprecated
func (*AckRange) GetSeqnumEnd ¶
func (*AckRange) GetSeqnumStart ¶
func (*AckRange) ProtoMessage ¶
func (*AckRange) ProtoMessage()
func (*AckRange) ProtoReflect ¶
func (x *AckRange) ProtoReflect() protoreflect.Message
type Bye ¶
type Bye struct {
// contains filtered or unexported fields
}
func (*Bye) Descriptor
deprecated
func (*Bye) ProtoMessage ¶
func (*Bye) ProtoMessage()
func (*Bye) ProtoReflect ¶
func (x *Bye) ProtoReflect() protoreflect.Message
type DataChannel ¶
type DataChannel struct { // Types that are assignable to Payload: // // *DataChannel_Heartbeat Payload isDataChannel_Payload `protobuf_oneof:"payload"` // contains filtered or unexported fields }
func (*DataChannel) Descriptor
deprecated
func (*DataChannel) Descriptor() ([]byte, []int)
Deprecated: Use DataChannel.ProtoReflect.Descriptor instead.
func (*DataChannel) GetHeartbeat ¶
func (x *DataChannel) GetHeartbeat() *DataChannelHeartbeat
func (*DataChannel) GetPayload ¶
func (m *DataChannel) GetPayload() isDataChannel_Payload
func (*DataChannel) ProtoMessage ¶
func (*DataChannel) ProtoMessage()
func (*DataChannel) ProtoReflect ¶
func (x *DataChannel) ProtoReflect() protoreflect.Message
func (*DataChannel) Reset ¶
func (x *DataChannel) Reset()
func (*DataChannel) String ¶
func (x *DataChannel) String() string
type DataChannelHeartbeat ¶
type DataChannelHeartbeat struct {
// contains filtered or unexported fields
}
func (*DataChannelHeartbeat) Descriptor
deprecated
func (*DataChannelHeartbeat) Descriptor() ([]byte, []int)
Deprecated: Use DataChannelHeartbeat.ProtoReflect.Descriptor instead.
func (*DataChannelHeartbeat) ProtoMessage ¶
func (*DataChannelHeartbeat) ProtoMessage()
func (*DataChannelHeartbeat) ProtoReflect ¶
func (x *DataChannelHeartbeat) ProtoReflect() protoreflect.Message
func (*DataChannelHeartbeat) Reset ¶
func (x *DataChannelHeartbeat) Reset()
func (*DataChannelHeartbeat) String ¶
func (x *DataChannelHeartbeat) String() string
type DataChannel_Heartbeat ¶
type DataChannel_Heartbeat struct {
Heartbeat *DataChannelHeartbeat `protobuf:"bytes,10,opt,name=heartbeat,proto3,oneof"`
}
type HTTPClient ¶
HTTPClient is the interface used by generated clients to send HTTP requests. It is fulfilled by *(net/http).Client, which is sufficient for most users. Users can provide their own implementation for special retry policies.
HTTPClient implementations should not follow redirects. Redirects are automatically disabled if *(net/http).Client is passed to client constructors. See the withoutRedirects function in this file for more details.
type ICECandidate ¶
type ICECandidate struct { Candidate string `protobuf:"bytes,1,opt,name=candidate,proto3" json:"candidate,omitempty"` SdpMLineIndex *uint32 `protobuf:"varint,2,opt,name=sdp_m_line_index,json=sdpMLineIndex,proto3,oneof" json:"sdp_m_line_index,omitempty"` SdpMid *string `protobuf:"bytes,3,opt,name=sdp_mid,json=sdpMid,proto3,oneof" json:"sdp_mid,omitempty"` Username *string `protobuf:"bytes,4,opt,name=username,proto3,oneof" json:"username,omitempty"` Password *string `protobuf:"bytes,5,opt,name=password,proto3,oneof" json:"password,omitempty"` // contains filtered or unexported fields }
func (*ICECandidate) Descriptor
deprecated
func (*ICECandidate) Descriptor() ([]byte, []int)
Deprecated: Use ICECandidate.ProtoReflect.Descriptor instead.
func (*ICECandidate) GetCandidate ¶
func (x *ICECandidate) GetCandidate() string
func (*ICECandidate) GetPassword ¶
func (x *ICECandidate) GetPassword() string
func (*ICECandidate) GetSdpMLineIndex ¶
func (x *ICECandidate) GetSdpMLineIndex() uint32
func (*ICECandidate) GetSdpMid ¶
func (x *ICECandidate) GetSdpMid() string
func (*ICECandidate) GetUsername ¶
func (x *ICECandidate) GetUsername() string
func (*ICECandidate) ProtoMessage ¶
func (*ICECandidate) ProtoMessage()
func (*ICECandidate) ProtoReflect ¶
func (x *ICECandidate) ProtoReflect() protoreflect.Message
func (*ICECandidate) Reset ¶
func (x *ICECandidate) Reset()
func (*ICECandidate) String ¶
func (x *ICECandidate) String() string
type IceServer ¶
type IceServer struct { Urls []string `protobuf:"bytes,1,rep,name=urls,proto3" json:"urls,omitempty"` Username *string `protobuf:"bytes,2,opt,name=username,proto3,oneof" json:"username,omitempty"` Credential *string `protobuf:"bytes,3,opt,name=credential,proto3,oneof" json:"credential,omitempty"` // contains filtered or unexported fields }
func (*IceServer) Descriptor
deprecated
func (*IceServer) GetCredential ¶
func (*IceServer) GetUsername ¶
func (*IceServer) ProtoMessage ¶
func (*IceServer) ProtoMessage()
func (*IceServer) ProtoReflect ¶
func (x *IceServer) ProtoReflect() protoreflect.Message
type Join ¶
type Join struct {
// contains filtered or unexported fields
}
func (*Join) Descriptor
deprecated
func (*Join) ProtoMessage ¶
func (*Join) ProtoMessage()
func (*Join) ProtoReflect ¶
func (x *Join) ProtoReflect() protoreflect.Message
type Message ¶
type Message struct { Header *MessageHeader `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` // payload will be treated as opaque in backend. Size limit is 10kB. Payload *MessagePayload `protobuf:"bytes,2,opt,name=payload,proto3" json:"payload,omitempty"` // contains filtered or unexported fields }
Use small tag numbers (1-15) for fields that are frequently used or are performance-sensitive, even if they are optional. Larger tag numbers (16 and above) can be used for fields that are optional and not frequently included in messages, as they will require more bytes to encode. Avoid the 19000–19999 range, as it's reserved. Consider future-proofing your schema by leaving gaps between field numbers to allow for extensions or new fields later.
func (*Message) Descriptor
deprecated
func (*Message) GetHeader ¶
func (x *Message) GetHeader() *MessageHeader
func (*Message) GetPayload ¶
func (x *Message) GetPayload() *MessagePayload
func (*Message) ProtoMessage ¶
func (*Message) ProtoMessage()
func (*Message) ProtoReflect ¶
func (x *Message) ProtoReflect() protoreflect.Message
type MessageHeader ¶
type MessageHeader struct { GroupId string `protobuf:"bytes,1,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` PeerId string `protobuf:"bytes,2,opt,name=peer_id,json=peerId,proto3" json:"peer_id,omitempty"` // where this message is originated from. Special values: "SYSTEM" ConnId uint32 `protobuf:"varint,3,opt,name=conn_id,json=connId,proto3" json:"conn_id,omitempty"` // used for deciding polite vs impolite. higher id wins. It also is used to detect connection breakages OtherGroupId string `protobuf:"bytes,4,opt,name=other_group_id,json=otherGroupId,proto3" json:"other_group_id,omitempty"` OtherPeerId string `protobuf:"bytes,5,opt,name=other_peer_id,json=otherPeerId,proto3" json:"other_peer_id,omitempty"` // Special values: "SYSTEM" OtherConnId uint32 `protobuf:"varint,6,opt,name=other_conn_id,json=otherConnId,proto3" json:"other_conn_id,omitempty"` // Special values: 0-16 Seqnum uint32 `protobuf:"varint,7,opt,name=seqnum,proto3" json:"seqnum,omitempty"` Reliable bool `protobuf:"varint,8,opt,name=reliable,proto3" json:"reliable,omitempty"` // true: tcp like, false: fire & forget // contains filtered or unexported fields }
func (*MessageHeader) Descriptor
deprecated
func (*MessageHeader) Descriptor() ([]byte, []int)
Deprecated: Use MessageHeader.ProtoReflect.Descriptor instead.
func (*MessageHeader) GetConnId ¶
func (x *MessageHeader) GetConnId() uint32
func (*MessageHeader) GetGroupId ¶
func (x *MessageHeader) GetGroupId() string
func (*MessageHeader) GetOtherConnId ¶
func (x *MessageHeader) GetOtherConnId() uint32
func (*MessageHeader) GetOtherGroupId ¶
func (x *MessageHeader) GetOtherGroupId() string
func (*MessageHeader) GetOtherPeerId ¶
func (x *MessageHeader) GetOtherPeerId() string
func (*MessageHeader) GetPeerId ¶
func (x *MessageHeader) GetPeerId() string
func (*MessageHeader) GetReliable ¶
func (x *MessageHeader) GetReliable() bool
func (*MessageHeader) GetSeqnum ¶
func (x *MessageHeader) GetSeqnum() uint32
func (*MessageHeader) ProtoMessage ¶
func (*MessageHeader) ProtoMessage()
func (*MessageHeader) ProtoReflect ¶
func (x *MessageHeader) ProtoReflect() protoreflect.Message
func (*MessageHeader) Reset ¶
func (x *MessageHeader) Reset()
func (*MessageHeader) String ¶
func (x *MessageHeader) String() string
type MessagePayload ¶
type MessagePayload struct { // Types that are assignable to PayloadType: // // *MessagePayload_Signal // *MessagePayload_Join // *MessagePayload_Bye // *MessagePayload_Ack PayloadType isMessagePayload_PayloadType `protobuf_oneof:"payload_type"` // contains filtered or unexported fields }
func (*MessagePayload) Descriptor
deprecated
func (*MessagePayload) Descriptor() ([]byte, []int)
Deprecated: Use MessagePayload.ProtoReflect.Descriptor instead.
func (*MessagePayload) GetAck ¶
func (x *MessagePayload) GetAck() *Ack
func (*MessagePayload) GetBye ¶
func (x *MessagePayload) GetBye() *Bye
func (*MessagePayload) GetJoin ¶
func (x *MessagePayload) GetJoin() *Join
func (*MessagePayload) GetPayloadType ¶
func (m *MessagePayload) GetPayloadType() isMessagePayload_PayloadType
func (*MessagePayload) GetSignal ¶
func (x *MessagePayload) GetSignal() *Signal
func (*MessagePayload) ProtoMessage ¶
func (*MessagePayload) ProtoMessage()
func (*MessagePayload) ProtoReflect ¶
func (x *MessagePayload) ProtoReflect() protoreflect.Message
func (*MessagePayload) Reset ¶
func (x *MessagePayload) Reset()
func (*MessagePayload) String ¶
func (x *MessagePayload) String() string
type MessagePayload_Ack ¶
type MessagePayload_Ack struct {
Ack *Ack `protobuf:"bytes,4,opt,name=ack,proto3,oneof"`
}
type MessagePayload_Bye ¶
type MessagePayload_Bye struct {
Bye *Bye `protobuf:"bytes,3,opt,name=bye,proto3,oneof"`
}
type MessagePayload_Join ¶
type MessagePayload_Join struct {
Join *Join `protobuf:"bytes,2,opt,name=join,proto3,oneof"`
}
type MessagePayload_Signal ¶
type MessagePayload_Signal struct {
Signal *Signal `protobuf:"bytes,1,opt,name=signal,proto3,oneof"`
}
type PeerInfo ¶
type PeerInfo struct { ConnId uint32 `protobuf:"varint,1,opt,name=conn_id,json=connId,proto3" json:"conn_id,omitempty"` EnableDiscovery bool `protobuf:"varint,2,opt,name=enable_discovery,json=enableDiscovery,proto3" json:"enable_discovery,omitempty"` // contains filtered or unexported fields }
func (*PeerInfo) Descriptor
deprecated
func (*PeerInfo) GetEnableDiscovery ¶
func (*PeerInfo) ProtoMessage ¶
func (*PeerInfo) ProtoMessage()
func (*PeerInfo) ProtoReflect ¶
func (x *PeerInfo) ProtoReflect() protoreflect.Message
type PrepareReq ¶
type PrepareReq struct {
// contains filtered or unexported fields
}
func (*PrepareReq) Descriptor
deprecated
func (*PrepareReq) Descriptor() ([]byte, []int)
Deprecated: Use PrepareReq.ProtoReflect.Descriptor instead.
func (*PrepareReq) ProtoMessage ¶
func (*PrepareReq) ProtoMessage()
func (*PrepareReq) ProtoReflect ¶
func (x *PrepareReq) ProtoReflect() protoreflect.Message
func (*PrepareReq) Reset ¶
func (x *PrepareReq) Reset()
func (*PrepareReq) String ¶
func (x *PrepareReq) String() string
type PrepareResp ¶
type PrepareResp struct { IceServers []*IceServer `protobuf:"bytes,1,rep,name=ice_servers,json=iceServers,proto3" json:"ice_servers,omitempty"` // contains filtered or unexported fields }
func (*PrepareResp) Descriptor
deprecated
func (*PrepareResp) Descriptor() ([]byte, []int)
Deprecated: Use PrepareResp.ProtoReflect.Descriptor instead.
func (*PrepareResp) GetIceServers ¶
func (x *PrepareResp) GetIceServers() []*IceServer
func (*PrepareResp) ProtoMessage ¶
func (*PrepareResp) ProtoMessage()
func (*PrepareResp) ProtoReflect ¶
func (x *PrepareResp) ProtoReflect() protoreflect.Message
func (*PrepareResp) Reset ¶
func (x *PrepareResp) Reset()
func (*PrepareResp) String ¶
func (x *PrepareResp) String() string
type RecvReq ¶
type RecvReq struct { Info *PeerInfo `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` // contains filtered or unexported fields }
func (*RecvReq) Descriptor
deprecated
func (*RecvReq) ProtoMessage ¶
func (*RecvReq) ProtoMessage()
func (*RecvReq) ProtoReflect ¶
func (x *RecvReq) ProtoReflect() protoreflect.Message
type RecvResp ¶
type RecvResp struct { Msgs []*Message `protobuf:"bytes,1,rep,name=msgs,proto3" json:"msgs,omitempty"` // contains filtered or unexported fields }
func (*RecvResp) Descriptor
deprecated
func (*RecvResp) ProtoMessage ¶
func (*RecvResp) ProtoMessage()
func (*RecvResp) ProtoReflect ¶
func (x *RecvResp) ProtoReflect() protoreflect.Message
type Sdp ¶
type Sdp struct { Kind SdpKind `protobuf:"varint,1,opt,name=kind,proto3,enum=service.rpc.v1.SdpKind" json:"kind,omitempty"` Sdp string `protobuf:"bytes,2,opt,name=sdp,proto3" json:"sdp,omitempty"` // contains filtered or unexported fields }
func (*Sdp) Descriptor
deprecated
func (*Sdp) ProtoMessage ¶
func (*Sdp) ProtoMessage()
func (*Sdp) ProtoReflect ¶
func (x *Sdp) ProtoReflect() protoreflect.Message
type SdpKind ¶
type SdpKind int32
func (SdpKind) Descriptor ¶
func (SdpKind) Descriptor() protoreflect.EnumDescriptor
func (SdpKind) EnumDescriptor
deprecated
func (SdpKind) Number ¶
func (x SdpKind) Number() protoreflect.EnumNumber
func (SdpKind) Type ¶
func (SdpKind) Type() protoreflect.EnumType
type SendReq ¶
type SendReq struct { Msg *Message `protobuf:"bytes,1,opt,name=msg,proto3" json:"msg,omitempty"` // contains filtered or unexported fields }
func (*SendReq) Descriptor
deprecated
func (*SendReq) ProtoMessage ¶
func (*SendReq) ProtoMessage()
func (*SendReq) ProtoReflect ¶
func (x *SendReq) ProtoReflect() protoreflect.Message
type SendResp ¶
type SendResp struct {
// contains filtered or unexported fields
}
func (*SendResp) Descriptor
deprecated
func (*SendResp) ProtoMessage ¶
func (*SendResp) ProtoMessage()
func (*SendResp) ProtoReflect ¶
func (x *SendResp) ProtoReflect() protoreflect.Message
type Signal ¶
type Signal struct { GenerationCounter uint32 `protobuf:"varint,1,opt,name=generation_counter,json=generationCounter,proto3" json:"generation_counter,omitempty"` // reserved for headers // // Types that are assignable to Data: // // *Signal_Sdp // *Signal_IceCandidate Data isSignal_Data `protobuf_oneof:"data"` // contains filtered or unexported fields }
func (*Signal) Descriptor
deprecated
func (*Signal) GetGenerationCounter ¶
func (*Signal) GetIceCandidate ¶
func (x *Signal) GetIceCandidate() *ICECandidate
func (*Signal) ProtoMessage ¶
func (*Signal) ProtoMessage()
func (*Signal) ProtoReflect ¶
func (x *Signal) ProtoReflect() protoreflect.Message
type Signal_IceCandidate ¶
type Signal_IceCandidate struct {
IceCandidate *ICECandidate `protobuf:"bytes,10,opt,name=ice_candidate,json=iceCandidate,proto3,oneof"`
}
type Signal_Sdp ¶
type Signal_Sdp struct {
Sdp *Sdp `protobuf:"bytes,9,opt,name=sdp,proto3,oneof"`
}
type Tunnel ¶
type Tunnel interface { Prepare(context.Context, *PrepareReq) (*PrepareResp, error) Send(context.Context, *SendReq) (*SendResp, error) Recv(context.Context, *RecvReq) (*RecvResp, error) }
func NewTunnelJSONClient ¶
func NewTunnelJSONClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Tunnel
NewTunnelJSONClient creates a JSON client that implements the Tunnel interface. It communicates using JSON and can be configured with a custom HTTPClient.
func NewTunnelProtobufClient ¶
func NewTunnelProtobufClient(baseURL string, client HTTPClient, opts ...twirp.ClientOption) Tunnel
NewTunnelProtobufClient creates a Protobuf client that implements the Tunnel interface. It communicates using Protobuf and can be configured with a custom HTTPClient.
type TwirpServer ¶
type TwirpServer interface { http.Handler // ServiceDescriptor returns gzipped bytes describing the .proto file that // this service was generated from. Once unzipped, the bytes can be // unmarshalled as a // google.golang.org/protobuf/types/descriptorpb.FileDescriptorProto. // // The returned integer is the index of this particular service within that // FileDescriptorProto's 'Service' slice of ServiceDescriptorProtos. This is a // low-level field, expected to be used for reflection. ServiceDescriptor() ([]byte, int) // ProtocGenTwirpVersion is the semantic version string of the version of // twirp used to generate this file. ProtocGenTwirpVersion() string // PathPrefix returns the HTTP URL path prefix for all methods handled by this // service. This can be used with an HTTP mux to route Twirp requests. // The path prefix is in the form: "/<prefix>/<package>.<Service>/" // that is, everything in a Twirp route except for the <Method> at the end. PathPrefix() string }
TwirpServer is the interface generated server structs will support: they're HTTP handlers with additional methods for accessing metadata about the service. Those accessors are a low-level API for building reflection tools. Most people can think of TwirpServers as just http.Handlers.
func NewTunnelServer ¶
func NewTunnelServer(svc Tunnel, opts ...interface{}) TwirpServer
NewTunnelServer builds a TwirpServer that can be used as an http.Handler to handle HTTP requests that are routed to the right method in the provided svc implementation. The opts are twirp.ServerOption modifiers, for example twirp.WithServerHooks(hooks).