refactor(openflare): unify protocol API responses to Wavelet format

Migrate Agent/Relay/Tunnel handlers from compat {success,message,data}
to response.OK and response.Abort* with real HTTP status codes. Remove
the compat package and update openflare-agent, openflare-relay, and
openflared clients to parse {error_msg,data}.
This commit is contained in:
ryan
2026-06-19 11:23:12 +08:00
parent 42ca0ec642
commit 33b4123444
18 changed files with 230 additions and 358 deletions
+6 -10
View File
@@ -3,17 +3,13 @@ package protocol
import "encoding/json"
type APIResponse[T any] struct {
Success bool `json:"success"`
Message string `json:"message"`
Data T `json:"data"`
ErrorMsg string `json:"error_msg"`
Data T `json:"data"`
}
type HeartbeatAPIResponse struct {
Success bool `json:"success"`
Message string `json:"message"`
Data any `json:"data"`
AgentSettings *AgentSettings `json:"agent_settings,omitempty"`
ActiveConfig *ActiveConfigMeta `json:"active_config,omitempty"`
type HeartbeatData struct {
AgentSettings *AgentSettings `json:"agent_settings"`
ActiveConfig *ActiveConfigMeta `json:"active_config"`
WAFIPGroups []WAFIPGroup `json:"waf_ip_groups,omitempty"`
}
@@ -208,4 +204,4 @@ type WAFIPGroupSyncResponse struct {
type SupportFile struct {
Path string `json:"path"`
Content string `json:"content"`
}
}