Add server-side hydration of initial config+status. Closes #1964

This commit is contained in:
Gabe Kangas
2022-09-10 15:37:07 -07:00
parent 92ef860387
commit 42ff0cdb01
6 changed files with 114 additions and 16 deletions

View File

@@ -61,6 +61,14 @@ func GetWebConfig(w http.ResponseWriter, r *http.Request) {
middleware.DisableCache(w)
w.Header().Set("Content-Type", "application/json")
configuration := getConfigResponse()
if err := json.NewEncoder(w).Encode(configuration); err != nil {
BadRequestHandler(w, err)
}
}
func getConfigResponse() webConfigResponse {
pageContent := utils.RenderPageContentMarkdown(data.GetExtraPageBodyContent())
socialHandles := data.GetSocialHandles()
for i, handle := range socialHandles {
@@ -106,7 +114,7 @@ func GetWebConfig(w http.ResponseWriter, r *http.Request) {
IndieAuthEnabled: data.GetServerURL() != "",
}
configuration := webConfigResponse{
return webConfigResponse{
Name: data.GetServerName(),
Summary: serverSummary,
OfflineMessage: data.GetCustomOfflineMessage(),
@@ -126,10 +134,6 @@ func GetWebConfig(w http.ResponseWriter, r *http.Request) {
Notifications: notificationsResponse,
Authentication: authenticationResponse,
}
if err := json.NewEncoder(w).Encode(configuration); err != nil {
BadRequestHandler(w, err)
}
}
// GetAllSocialPlatforms will return a list of all social platform types.