refactor(api): fetchAllConfigs 接口从 GET 改为 POST
- 服务端: 新增 FetchAllRequest 结构体,参数通过 JSON body 传递 - 服务端: 路由从 api.GET 改为 api.POST - Go/Python/Node.js/Java 客户端同步更新为 POST + JSON body - 与 fetchChangedConfigs 接口风格统一,token 不再暴露在 URL 中
This commit is contained in:
+16
-3
@@ -1,6 +1,7 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
@@ -107,14 +108,26 @@ func (c *Client) Stop() {
|
||||
}
|
||||
|
||||
func (c *Client) fetchAll() error {
|
||||
url := fmt.Sprintf("%s/api/fetchAllConfigs?appName=%s&env=%s&version=%s&ignoreGlobal=%v",
|
||||
c.config.BaseURL, c.config.AppName, c.config.Env, c.config.Version, c.config.IgnoreGlobal)
|
||||
url := fmt.Sprintf("%s/api/fetchAllConfigs", c.config.BaseURL)
|
||||
|
||||
req, err := http.NewRequest("GET", url, nil)
|
||||
payload := map[string]interface{}{
|
||||
"appName": c.config.AppName,
|
||||
"env": c.config.Env,
|
||||
"version": c.config.Version,
|
||||
"ignoreGlobal": c.config.IgnoreGlobal,
|
||||
"token": c.config.Token,
|
||||
}
|
||||
payloadBytes, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
req, err := http.NewRequest("POST", url, bytes.NewReader(payloadBytes))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := c.httpClient.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user