package main import ( "fmt" "io" "log" "net/http" "testing" ) func TestConfigMeta(t *testing.T) { httpClient := &http.Client{} url := "http://localhost:8080/api/init/config/meta" req, err := http.NewRequest("POST", url, nil) if err != nil { log.Printf("NewRequest:%v", err) } req.Header.Set("Authorization", "Bearer 123") req.Header.Set("Content-Type", "application/json") resp, err := httpClient.Do(req) if err != nil { fmt.Printf("发送请求失败: %v\n", err) return } defer resp.Body.Close() // 读取响应 body, err := io.ReadAll(resp.Body) if err != nil { fmt.Printf("读取响应失败: %v\n", err) return } fmt.Printf("状态码: %d\n", resp.StatusCode) fmt.Printf("响应体: %s\n", string(body)) }