mirror of
https://github.com/owncast/owncast.git
synced 2024-11-24 05:38:58 +03:00
85e7af3d5f
* chore(go): update go version to 1.20. Closes #2185 * chore(go): run better align against project To optimize struct field order. Closes #2870 * chore(go): update CI jobs to use Go 1.20 * fix(go): linter warnings for Go 1.20 update
52 lines
1.9 KiB
Go
52 lines
1.9 KiB
Go
package admin
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
|
|
"github.com/owncast/owncast/core"
|
|
"github.com/owncast/owncast/core/data"
|
|
"github.com/owncast/owncast/metrics"
|
|
"github.com/owncast/owncast/models"
|
|
"github.com/owncast/owncast/router/middleware"
|
|
log "github.com/sirupsen/logrus"
|
|
)
|
|
|
|
// Status gets the details of the inbound broadcaster.
|
|
func Status(w http.ResponseWriter, r *http.Request) {
|
|
broadcaster := core.GetBroadcaster()
|
|
status := core.GetStatus()
|
|
currentBroadcast := core.GetCurrentBroadcast()
|
|
health := metrics.GetStreamHealthOverview()
|
|
response := adminStatusResponse{
|
|
Broadcaster: broadcaster,
|
|
CurrentBroadcast: currentBroadcast,
|
|
Online: status.Online,
|
|
Health: health,
|
|
ViewerCount: status.ViewerCount,
|
|
OverallPeakViewerCount: status.OverallMaxViewerCount,
|
|
SessionPeakViewerCount: status.SessionMaxViewerCount,
|
|
VersionNumber: status.VersionNumber,
|
|
StreamTitle: data.GetStreamTitle(),
|
|
}
|
|
|
|
w.Header().Set("Content-Type", "application/json")
|
|
middleware.DisableCache(w)
|
|
|
|
err := json.NewEncoder(w).Encode(response)
|
|
if err != nil {
|
|
log.Errorln(err)
|
|
}
|
|
}
|
|
|
|
type adminStatusResponse struct {
|
|
Broadcaster *models.Broadcaster `json:"broadcaster"`
|
|
CurrentBroadcast *models.CurrentBroadcast `json:"currentBroadcast"`
|
|
Health *models.StreamHealthOverview `json:"health"`
|
|
StreamTitle string `json:"streamTitle"`
|
|
VersionNumber string `json:"versionNumber"`
|
|
ViewerCount int `json:"viewerCount"`
|
|
OverallPeakViewerCount int `json:"overallPeakViewerCount"`
|
|
SessionPeakViewerCount int `json:"sessionPeakViewerCount"`
|
|
Online bool `json:"online"`
|
|
}
|