MCPcopy Create free account
hub / github.com/chainloop-dev/chainloop / HTTPGetJSON

Function HTTPGetJSON

labs/wasm-policy-sdk/go/http.go:41–52  ·  view source on GitHub ↗

HTTPGetJSON performs a GET request and unmarshals the JSON response. Only hostnames configured in the policy engine's AllowedHosts are accessible.

(url string, target interface{})

Source from the content-addressed store, hash-verified

39// HTTPGetJSON performs a GET request and unmarshals the JSON response.
40// Only hostnames configured in the policy engine's AllowedHosts are accessible.
41func HTTPGetJSON(url string, target interface{}) error {
42 body, err := HTTPGet(url)
43 if err != nil {
44 return err
45 }
46
47 if err := json.Unmarshal(body, target); err != nil {
48 return fmt.Errorf("failed to unmarshal JSON response: %w", err)
49 }
50
51 return nil
52}
53
54// HTTPGetString performs a GET request and returns the response as a string.
55// Only hostnames configured in the policy engine's AllowedHosts are accessible.

Callers

nothing calls this directly

Calls 1

HTTPGetFunction · 0.85

Tested by

no test coverage detected