1
0
mirror of https://gitlab.crans.org/nounous/ghostream.git synced 2024-12-22 18:32:19 +00:00

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

View File

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