Viewer metrics api (#208)
* Add support for ending the inbound stream. Closes #191 * Add a simple success response to API requests * Add viewers over time API * Move controllers to admin directory
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package controllers
|
||||
package admin
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
15
controllers/admin/viewers.go
Normal file
15
controllers/admin/viewers.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package admin
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
|
||||
"github.com/gabek/owncast/metrics"
|
||||
)
|
||||
|
||||
// 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")
|
||||
json.NewEncoder(w).Encode(viewersOverTime)
|
||||
}
|
||||
Reference in New Issue
Block a user