mirror of
https://github.com/livekit/livekit.git
synced 2026-10-22 19:43:01 +00:00
Drive-by misc changes. (#3399)
While working on a different service, noticed delegation of setting up routes to the service itself. So, making that change and making some methods internal only as there is no need to export them outside the service.
This commit is contained in:
1 parent
7ff4082e4a
commit
bb0ee1139c
2 files changed
+9
-5
No files matched your search
@@ -91,8 +91,12 @@ func NewRTCService(
|
||||
return s
|
||||
}
|
||||
|
||||
func (s *RTCService) Validate(w http.ResponseWriter, r *http.Request) {
|
||||
_, _, code, err := s.validate(r)
|
||||
func (s *RTCService) SetupRoutes(mux *http.ServeMux) {
|
||||
mux.HandleFunc("/validate", s.validate)
|
||||
}
|
||||
|
||||
func (s *RTCService) validate(w http.ResponseWriter, r *http.Request) {
|
||||
_, _, code, err := s.validateInternal(r)
|
||||
if err != nil {
|
||||
handleError(w, r, code, err)
|
||||
return
|
||||
@@ -100,7 +104,7 @@ func (s *RTCService) Validate(w http.ResponseWriter, r *http.Request) {
|
||||
_, _ = w.Write([]byte("success"))
|
||||
}
|
||||
|
||||
func (s *RTCService) validate(r *http.Request) (livekit.RoomName, routing.ParticipantInit, int, error) {
|
||||
func (s *RTCService) validateInternal(r *http.Request) (livekit.RoomName, routing.ParticipantInit, int, error) {
|
||||
claims := GetGrants(r.Context())
|
||||
var pi routing.ParticipantInit
|
||||
|
||||
@@ -214,7 +218,7 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
roomName, pi, code, err := s.validate(r)
|
||||
roomName, pi, code, err := s.validateInternal(r)
|
||||
if err != nil {
|
||||
handleError(w, r, code, err)
|
||||
return
|
||||
|
||||
@@ -134,8 +134,8 @@ func NewLivekitServer(conf *config.Config,
|
||||
mux.Handle(ingressServer.PathPrefix(), ingressServer)
|
||||
mux.Handle(sipServer.PathPrefix(), sipServer)
|
||||
mux.Handle("/rtc", rtcService)
|
||||
rtcService.SetupRoutes(mux)
|
||||
mux.Handle("/agent", agentService)
|
||||
mux.HandleFunc("/rtc/validate", rtcService.Validate)
|
||||
mux.HandleFunc("/", s.defaultHandler)
|
||||
|
||||
s.httpServer = &http.Server{
|
||||
|
||||
Reference in new issue
Block a user