feat(system): add system status and software info endpoints

Add new endpoints to expose system status and software information:
- /system/getStatus returns current system status (online/offline)
- /system/getSoftwareInfo returns software version and build details
Update API documentation to include new endpoints
This commit is contained in:
2026-03-09 19:02:56 +08:00
parent 8b9a757bea
commit a142fb17a8
3 changed files with 89 additions and 2 deletions
+23 -1
View File
@@ -20,10 +20,17 @@ type SoftwareInfo struct {
BuildType string
}
var softwareInfo SoftwareInfo
type StatusInfo struct {
Status string
}
var isDebug bool
var isOnline bool
func main() {
softwareInfo := SoftwareInfo{
softwareInfo = SoftwareInfo{
Name: "Super-frpc",
Version: "0.0.1",
Developer: "Madobi Nanami",
@@ -85,6 +92,7 @@ func main() {
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
postLog.Fatal(fmt.Sprintf("Failed to start server: %v", err))
}
isOnline = true
}()
go func() {
@@ -116,3 +124,17 @@ func main() {
postLog.Info("Server stopped")
}
func GetStatusHandler(w http.ResponseWriter, r *http.Request) {
statusInfo := StatusInfo{
Status: "Online",
}
if !isOnline {
statusInfo.Status = "Offline"
}
SendSuccessResponse(w, "getStatus", statusInfo)
}
func GetSoftwareInfoHandler(w http.ResponseWriter, r *http.Request) {
SendSuccessResponse(w, "getSoftwareInfo", softwareInfo)
}