feat(client): 配置拉取请求中添加 token 认证字段

- 请求 payload 中新增 token 字段,将配置中的 Token 传递给服务端
- 新增 client_test.go 验证 fetchChanged 正确发送 token 和 lastTime
This commit is contained in:
2026-09-03 21:15:18 +08:00
parent a62dbfe74c
commit c0a7631d5c
2 changed files with 46 additions and 2 deletions
+3 -2
View File
@@ -181,6 +181,7 @@ func (c *Client) fetchChanged() error {
"version": c.config.Version,
"lastTime": c.lastTime,
"ignoreGlobal": c.config.IgnoreGlobal,
"token": c.config.Token,
}
payloadBytes, _ := json.Marshal(payload)
@@ -206,8 +207,8 @@ func (c *Client) fetchChanged() error {
}
var wrapper struct {
Code int `json:"code"`
Data map[string]string `json:"data"`
Code int `json:"code"`
Data map[string]string `json:"data"`
}
if err := json.Unmarshal(body, &wrapper); err != nil {
return err