mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-07 08:06:37 +08:00
[优化] ui优化
This commit is contained in:
@@ -54,7 +54,6 @@ func (c *Client) Heartbeat(ctx context.Context, payload protocol.NodePayload) (*
|
||||
}
|
||||
|
||||
func (c *Client) GetActiveConfig(ctx context.Context) (*protocol.ActiveConfigResponse, error) {
|
||||
log.Printf("http get active config request")
|
||||
resp := protocol.APIResponse[protocol.ActiveConfigResponse]{}
|
||||
if err := c.getJSON(ctx, "/api/agent/config-versions/active", &resp); err != nil {
|
||||
return nil, err
|
||||
@@ -100,9 +99,6 @@ func (c *Client) postJSON(ctx context.Context, path string, body any, target any
|
||||
}
|
||||
|
||||
func (c *Client) do(req *http.Request, target any) error {
|
||||
if !isHeartbeatRequest(req) {
|
||||
log.Printf("http request start: method=%s path=%s", req.Method, req.URL.Path)
|
||||
}
|
||||
res, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
log.Printf("http request failed: method=%s path=%s error=%v", req.Method, req.URL.Path, err)
|
||||
@@ -123,24 +119,11 @@ func (c *Client) do(req *http.Request, target any) error {
|
||||
log.Printf("http api response failed: method=%s path=%s message=%s", req.Method, req.URL.Path, wrapper.Message)
|
||||
return errors.New(wrapper.Message)
|
||||
}
|
||||
if !isHeartbeatRequest(req) {
|
||||
log.Printf("http request succeeded: method=%s path=%s", req.Method, req.URL.Path)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
if err = json.NewDecoder(res.Body).Decode(target); err != nil {
|
||||
log.Printf("http response decode failed: method=%s path=%s error=%v", req.Method, req.URL.Path, err)
|
||||
return err
|
||||
}
|
||||
if !isHeartbeatRequest(req) {
|
||||
log.Printf("http request succeeded: method=%s path=%s", req.Method, req.URL.Path)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func isHeartbeatRequest(req *http.Request) bool {
|
||||
if req == nil || req.URL == nil {
|
||||
return false
|
||||
}
|
||||
return req.Method == http.MethodPost && req.URL.Path == "/api/agent/nodes/heartbeat"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user