httpserver

package
v1.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const SessionTTL = time.Second * 30

Variables

This section is empty.

Functions

func StartHTTPServer

func StartHTTPServer(lc fx.Lifecycle, c *ConnectHandler, address AddressType,
	logger *zap.SugaredLogger) *http.Server

StartHTTPServer starts a http server that listens to the given address and serves the connect endpoint.

Types

type AddressType

type AddressType string

type AuthBackend

type AuthBackend interface {
	// IsAthorized checks if the fingerprint is authorized to connect
	IsAuthorized(tokens ...string) bool
}

type ConnectHandler

type ConnectHandler struct {
	// contains filtered or unexported fields
}

func NewConnectHandler

func NewConnectHandler(
	backend AuthBackend, conf *peers.Conf, logger *zap.SugaredLogger) *ConnectHandler

func (*ConnectHandler) AddHandlers added in v1.3.0

func (h *ConnectHandler) AddHandlers(mux *http.ServeMux)

func (*ConnectHandler) GetHandler added in v1.3.0

func (h *ConnectHandler) GetHandler() http.Handler

func (*ConnectHandler) HandleCandidate added in v1.3.0

func (h *ConnectHandler) HandleCandidate(w http.ResponseWriter, r *http.Request)

HandleCandidate is called when a client requests the candidate endpoint it should be a patch and the body webrtc's client candidate.

func (*ConnectHandler) HandleConnect

func (h *ConnectHandler) HandleConnect(w http.ResponseWriter, r *http.Request)

HandleConnect is called when a client requests the connect endpoint it should be a post and the body webrtc's client offer. In reponse the handlers send the server's webrtc's offer.

func (*ConnectHandler) HandleOffer added in v1.3.0

func (h *ConnectHandler) HandleOffer(w http.ResponseWriter, r *http.Request)

HandleOffer is called when a client requests the whip endpoint it should be a post and the body webrtc's client offer. In reponse the handlers send the server's webrtc's offer.

func (*ConnectHandler) IsAuthorized added in v1.3.0

func (h *ConnectHandler) IsAuthorized(r *http.Request, fp string) bool

type ConnectRequest

type ConnectRequest struct {
	Fingerprint string `json:"fingerprint"`
	APIVer      int    `json:"api_version"`
	Offer       string `json:"offer"`
}

ConnectRequest is the schema for the connect POST request

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL