mirror of
https://github.com/owncast/owncast.git
synced 2024-12-18 07:12:33 +03:00
Revert "Consolidate the ping and status request APIs"
This reverts commit b96cd2e93e
.
This commit is contained in:
parent
f2b2e5c61c
commit
bb8aea6446
3 changed files with 24 additions and 12 deletions
13
controllers/ping.go
Normal file
13
controllers/ping.go
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"github.com/owncast/owncast/core"
|
||||||
|
"github.com/owncast/owncast/utils"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Ping(w http.ResponseWriter, r *http.Request) {
|
||||||
|
id := utils.GenerateClientIDFromRequest(r)
|
||||||
|
core.SetViewerIdActive(id)
|
||||||
|
}
|
|
@ -15,27 +15,23 @@ func GetStatus(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
||||||
status := core.GetStatus()
|
status := core.GetStatus()
|
||||||
response := webStatusResponse{
|
response := webStatusResponse{
|
||||||
Online: status.Online,
|
Online: status.Online,
|
||||||
ViewerCount: status.ViewerCount,
|
ViewerCount: status.ViewerCount,
|
||||||
LastConnectTime: status.LastConnectTime,
|
LastConnectTime: status.LastConnectTime,
|
||||||
LastDisconnectTime: status.LastDisconnectTime,
|
LastDisconnectTime: status.LastDisconnectTime,
|
||||||
VersionNumber: status.VersionNumber,
|
VersionNumber: status.VersionNumber,
|
||||||
StreamTitle: status.StreamTitle,
|
StreamTitle: status.StreamTitle,
|
||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||||
InternalErrorHandler(w, err)
|
InternalErrorHandler(w, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mark the user who requested this status as an active viewer
|
|
||||||
id := utils.GenerateClientIDFromRequest(r)
|
|
||||||
core.SetViewerIdActive(id)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type webStatusResponse struct {
|
type webStatusResponse struct {
|
||||||
Online bool `json:"online"`
|
Online bool `json:"online"`
|
||||||
ViewerCount int `json:"viewerCount"`
|
ViewerCount int `json:"viewerCount"`
|
||||||
|
|
||||||
LastConnectTime utils.NullTime `json:"lastConnectTime"`
|
LastConnectTime utils.NullTime `json:"lastConnectTime"`
|
||||||
LastDisconnectTime utils.NullTime `json:"lastDisconnectTime"`
|
LastDisconnectTime utils.NullTime `json:"lastDisconnectTime"`
|
||||||
|
|
|
@ -62,6 +62,9 @@ func Start() error {
|
||||||
// return the list of video variants available
|
// return the list of video variants available
|
||||||
http.HandleFunc("/api/video/variants", controllers.GetVideoStreamOutputVariants)
|
http.HandleFunc("/api/video/variants", controllers.GetVideoStreamOutputVariants)
|
||||||
|
|
||||||
|
// tell the backend you're an active viewer
|
||||||
|
http.HandleFunc("/api/ping", controllers.Ping)
|
||||||
|
|
||||||
// Authenticated admin requests
|
// Authenticated admin requests
|
||||||
|
|
||||||
// Current inbound broadcaster
|
// Current inbound broadcaster
|
||||||
|
|
Loading…
Reference in a new issue