+23
knotclient/unsigned.go
+23
knotclient/unsigned.go
···
52
52
return http.NewRequest(method, reqUrl.String(), bytes.NewReader(body))
53
53
}
54
54
55
+
func do[T any](us *UnsignedClient, req *http.Request) (*T, error) {
56
+
resp, err := us.client.Do(req)
57
+
if err != nil {
58
+
return nil, err
59
+
}
60
+
defer resp.Body.Close()
61
+
62
+
body, err := io.ReadAll(resp.Body)
63
+
if err != nil {
64
+
log.Printf("Error reading response body: %v", err)
65
+
return nil, err
66
+
}
67
+
68
+
var result T
69
+
err = json.Unmarshal(body, &result)
70
+
if err != nil {
71
+
log.Printf("Error unmarshalling response body: %v", err)
72
+
return nil, err
73
+
}
74
+
75
+
return &result, nil
76
+
}
77
+
55
78
func (us *UnsignedClient) Index(ownerDid, repoName, ref string) (*http.Response, error) {
56
79
const (
57
80
Method = "GET"