owncast/controllers/admin/viewers.go
Gabe Kangas 4d2066a76d
Start cleaning up linter errors. (#358)
* Start cleaning up linter errors. For #357

* Fix unmarshalling NullTime values

* More linter fixes

* Remove commented code

* Move defer up

* Consolidate error check lines

* Move error check to make sure row iteration was successful

* Cleaner error check + do not recreate pipe if it exists

* Consolidate hashing to generate client id
2020-11-14 18:39:53 -08:00

19 lines
458 B
Go

package admin
import (
"encoding/json"
"net/http"
"github.com/owncast/owncast/metrics"
log "github.com/sirupsen/logrus"
)
// 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)
}
}