Add server-side hydration of initial config+status. Closes #1964
This commit is contained in:
@@ -13,6 +13,17 @@ import (
|
||||
|
||||
// GetStatus gets the status of the server.
|
||||
func GetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
response := getStatusResponse()
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
middleware.DisableCache(w)
|
||||
|
||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||
InternalErrorHandler(w, err)
|
||||
}
|
||||
}
|
||||
|
||||
func getStatusResponse() webStatusResponse {
|
||||
status := core.GetStatus()
|
||||
response := webStatusResponse{
|
||||
Online: status.Online,
|
||||
@@ -22,17 +33,10 @@ func GetStatus(w http.ResponseWriter, r *http.Request) {
|
||||
VersionNumber: status.VersionNumber,
|
||||
StreamTitle: status.StreamTitle,
|
||||
}
|
||||
|
||||
if !data.GetHideViewerCount() {
|
||||
response.ViewerCount = status.ViewerCount
|
||||
}
|
||||
|
||||
w.Header().Set("Content-Type", "application/json")
|
||||
middleware.DisableCache(w)
|
||||
|
||||
if err := json.NewEncoder(w).Encode(response); err != nil {
|
||||
InternalErrorHandler(w, err)
|
||||
}
|
||||
return response
|
||||
}
|
||||
|
||||
type webStatusResponse struct {
|
||||
|
||||
Reference in New Issue
Block a user