|
@@ -7,6 +7,7 @@ import (
|
|
|
"godash/files"
|
|
|
"godash/hub"
|
|
|
"godash/message"
|
|
|
+ "godash/system"
|
|
|
"godash/weather"
|
|
|
"net/http"
|
|
|
)
|
|
@@ -16,6 +17,7 @@ type launchpadInformation struct {
|
|
|
Host string
|
|
|
Bookmarks []bookmark.Bookmark
|
|
|
Weather weather.OpenWeatherApiResponse
|
|
|
+ System system.LiveInformation
|
|
|
}
|
|
|
|
|
|
func launchpad(w http.ResponseWriter, r *http.Request) {
|
|
@@ -24,6 +26,7 @@ func launchpad(w http.ResponseWriter, r *http.Request) {
|
|
|
Title: "Godash",
|
|
|
Bookmarks: bookmark.Bookmarks,
|
|
|
Weather: weather.CurrentOpenWeather,
|
|
|
+ System: system.Sys.Live,
|
|
|
})
|
|
|
}
|
|
|
|
|
@@ -43,6 +46,38 @@ func getWeather(w http.ResponseWriter, r *http.Request) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+// @Schemes
|
|
|
+// @Summary live system information
|
|
|
+// @Description gets live information of the system
|
|
|
+// @Tags system
|
|
|
+// @Produce json
|
|
|
+// @Success 200 {object} system.LiveInformation
|
|
|
+// @Success 204 {object} message.Response
|
|
|
+// @Router /system/live [get]
|
|
|
+func routeLiveSystem(w http.ResponseWriter, r *http.Request) {
|
|
|
+ if system.Config.LiveSystem {
|
|
|
+ jsonResponse(w, system.Sys.Live, http.StatusOK)
|
|
|
+ } else {
|
|
|
+ jsonResponse(w, message.Response{Message: message.NotFound.String()}, http.StatusNoContent)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// @Schemes
|
|
|
+// @Summary static system information
|
|
|
+// @Description gets static information of the system
|
|
|
+// @Tags system
|
|
|
+// @Produce json
|
|
|
+// @Success 200 {object} system.StaticInformation
|
|
|
+// @Success 204 {object} message.Response
|
|
|
+// @Router /system/static [get]
|
|
|
+func routeStaticSystem(w http.ResponseWriter, r *http.Request) {
|
|
|
+ if system.Config.LiveSystem {
|
|
|
+ jsonResponse(w, system.Sys.Static, http.StatusOK)
|
|
|
+ } else {
|
|
|
+ jsonResponse(w, message.Response{Message: message.NotFound.String()}, http.StatusNoContent)
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
func webSocket(w http.ResponseWriter, r *http.Request) {
|
|
|
conn, err := upgrader.Upgrade(w, r, nil)
|
|
|
if err != nil {
|