feat(settings): add settings management API endpoints

- Add GET /settings/get and POST /settings/set endpoints for managing system settings
- Implement config file persistence for settings changes
- Update config schema to include notification and webhook settings
- Add API documentation for new endpoints
- Move config path variables to global package for consistency
This commit is contained in:
2026-04-23 12:43:11 +08:00
parent 489c37e095
commit ac51641e93
6 changed files with 303 additions and 16 deletions

View File

@@ -4,6 +4,10 @@ import (
"database/sql"
)
var ConfigPath *string
var DBPath_data *string
var DBPath_log *string
type SoftwareInfo struct {
Name string
Version string
@@ -49,13 +53,23 @@ type Config struct {
Enabled bool `json:"enabled"`
Port int `json:"port"`
} `json:"watchdog"`
Notification struct {
Enabled bool `json:"enabled"`
Method string `json:"method"`
} `json:"notification"`
Webhook struct {
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Body map[string]string `json:"body"`
} `json:"webhook"`
}
var CurrentConfig = Config{
ListenAddr: "0.0.0.0",
ListenPort: "7000",
FrpcPath: "/usr/bin/frpc",
InstancePath: "/var/lib/frpc",
FrpcPath: "",
InstancePath: "",
Debug: false,
Watchdog: struct {
Enabled bool `json:"enabled"`
@@ -64,4 +78,26 @@ var CurrentConfig = Config{
Enabled: false,
Port: 0,
},
Notification: struct {
Enabled bool `json:"enabled"`
Method string `json:"method"`
}{
Enabled: false,
Method: "webhook",
},
Webhook: struct {
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers"`
Body map[string]string `json:"body"`
}{
Method: "",
URL: "",
Headers: map[string]string{
"Content-Type": "",
},
Body: map[string]string{
"text": "",
},
},
}