Add default handler to 404 (#1088)

This commit is contained in:
Samuel Humeau
2022-10-16 10:30:34 -07:00
committed by GitHub
parent d6be3cab26
commit 00ec859dd1
+9 -1
View File
@@ -99,7 +99,7 @@ func NewLivekitServer(conf *config.Config,
mux.Handle(ingressServer.PathPrefix(), ingressServer)
mux.Handle("/rtc", rtcService)
mux.HandleFunc("/rtc/validate", rtcService.Validate)
mux.HandleFunc("/", s.healthCheck)
mux.HandleFunc("/", s.defaultHandler)
s.httpServer = &http.Server{
Handler: configureMiddlewares(mux, middlewares...),
@@ -302,6 +302,14 @@ func (s *LivekitServer) debugInfo(w http.ResponseWriter, _ *http.Request) {
}
}
func (s *LivekitServer) defaultHandler(w http.ResponseWriter, r *http.Request) {
if r.URL.Path == "/" {
s.healthCheck(w, r)
} else {
http.NotFound(w, r)
}
}
func (s *LivekitServer) healthCheck(w http.ResponseWriter, _ *http.Request) {
var updatedAt time.Time
if s.Node().Stats != nil {