Handle error

This commit is contained in:
Alexandre Iooss 2020-09-29 18:20:24 +02:00
parent 078a74add1
commit f8aa587d0e
No known key found for this signature in database
GPG Key ID: 6C79278F3FCDCC02
1 changed files with 5 additions and 1 deletions

View File

@ -88,7 +88,11 @@ func staticHandler() http.Handler {
func statisticsHandler(w http.ResponseWriter, r *http.Request) {
// Display connected users stats
enc := json.NewEncoder(w)
enc.Encode(struct {
err := enc.Encode(struct {
ConnectedViewers int
}{webrtc.GetNumberConnectedSessions()})
if err != nil {
http.Error(w, "Failed to generate JSON.", http.StatusInternalServerError)
log.Printf("Failed to generate JSON: %s", err)
}
}