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
+63 -1
View File
@@ -23,11 +23,73 @@ All API responses are returned in JSON format:
- For all requests: Authentication token and timestamp are sent in HTTP headers (prefixed with `X-`) - For all requests: Authentication token and timestamp are sent in HTTP headers (prefixed with `X-`)
- For **POST** requests: Other data is sent in the request body as JSON - For **POST** requests: Other data is sent in the request body as JSON
- For **GET** requests: All data is sent in HTTP headers (prefixed with `X-`) - For **GET** requests: All data is sent in HTTP headers (prefixed with `X-`)
- All requests require authentication (except `/register` and `/login`) - All requests require authentication (except `/register`, `/login`, `/system/getStatus`, `/system/getSoftwareInfo`)
- Timestamps are in milliseconds (Unix timestamp) - Timestamps are in milliseconds (Unix timestamp)
--- ---
## Get System Status
**Endpoint:** `/system/getStatus`
**Method:** GET
**Auth Required:** No
**Permission Level:** None
Get the current system status.
**Response:**
```json
{
"success": true,
"message": "getStatus",
"data": {
"Status": "Online"
}
}
```
| Field | Type | Description |
|-------|------|-------------|
| Status | string | System status: "Online" or "Offline" |
---
## Get Software Info
**Endpoint:** `/system/getSoftwareInfo`
**Method:** GET
**Auth Required:** No
**Permission Level:** None
Get software version and build information.
**Response:**
```json
{
"success": true,
"message": "getSoftwareInfo",
"data": {
"Name": "Super-frpc",
"Version": "0.0.1",
"Developer": "Madobi Nanami",
"BuildVer": 1,
"Description": "",
"BuildType": "debug"
}
}
```
| Field | Type | Description |
|-------|------|-------------|
| Name | string | Software name |
| Version | string | Software version |
| Developer | string | Developer name |
| BuildVer | int16 | Build version number |
| Description | string | Software description |
| BuildType | string | Build type: "debug" or "release" |
---
## Register User ## Register User
**Endpoint:** `/register` **Endpoint:** `/register`
+23 -1
View File
@@ -20,10 +20,17 @@ type SoftwareInfo struct {
BuildType string BuildType string
} }
var softwareInfo SoftwareInfo
type StatusInfo struct {
Status string
}
var isDebug bool var isDebug bool
var isOnline bool
func main() { func main() {
softwareInfo := SoftwareInfo{ softwareInfo = SoftwareInfo{
Name: "Super-frpc", Name: "Super-frpc",
Version: "0.0.1", Version: "0.0.1",
Developer: "Madobi Nanami", Developer: "Madobi Nanami",
@@ -85,6 +92,7 @@ func main() {
if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed { if err := server.ListenAndServe(); err != nil && err != http.ErrServerClosed {
postLog.Fatal(fmt.Sprintf("Failed to start server: %v", err)) postLog.Fatal(fmt.Sprintf("Failed to start server: %v", err))
} }
isOnline = true
}() }()
go func() { go func() {
@@ -116,3 +124,17 @@ func main() {
postLog.Info("Server stopped") 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)
}
+3
View File
@@ -8,6 +8,9 @@ import (
func setupRoutes() { func setupRoutes() {
postLog.Info("Setting up routes...") postLog.Info("Setting up routes...")
http.HandleFunc("/system/getStatus", GetStatusHandler)
http.HandleFunc("/system/getSoftwareInfo", GetSoftwareInfoHandler)
http.HandleFunc("/register", RegisterHandler) http.HandleFunc("/register", RegisterHandler)
http.HandleFunc("/login", LoginHandler) http.HandleFunc("/login", LoginHandler)
http.HandleFunc("/logout", LogoutHandler) http.HandleFunc("/logout", LogoutHandler)