owncast/controllers/admin/viewers.go

20 lines
458 B
Go
Raw Normal View History

package admin
import (
"encoding/json"
"net/http"
"github.com/owncast/owncast/metrics"
log "github.com/sirupsen/logrus"
)
2020-11-13 00:14:59 +01:00
// GetViewersOverTime will return the number of viewers at points in time.
func GetViewersOverTime(w http.ResponseWriter, r *http.Request) {
viewersOverTime := metrics.Metrics.Viewers
w.Header().Set("Content-Type", "application/json")
err := json.NewEncoder(w).Encode(viewersOverTime)
if err != nil {
log.Errorln(err)
}
}