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

Function HTTPGet

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

HTTPGet performs a GET request using Extism's built-in HTTP functionality. Only hostnames configured in the policy engine's AllowedHosts are accessible. Returns error if the hostname is not allowed or the request fails.

(url string)

Source from the content-addressed store, hash-verified

26// Only hostnames configured in the policy engine's AllowedHosts are accessible.
27// Returns error if the hostname is not allowed or the request fails.
28func HTTPGet(url string) ([]byte, error) {
29 req := pdk.NewHTTPRequest(pdk.MethodGet, url)
30 resp := req.Send()
31
32 if resp.Status() != 200 {
33 return nil, fmt.Errorf("HTTP request failed with status %d", resp.Status())
34 }
35
36 return resp.Body(), nil
37}
38
39// HTTPGetJSON performs a GET request and unmarshals the JSON response.
40// Only hostnames configured in the policy engine's AllowedHosts are accessible.

Callers 2

HTTPGetJSONFunction · 0.85
HTTPGetStringFunction · 0.85

Calls 2

BodyMethod · 0.80
StatusMethod · 0.45

Tested by

no test coverage detected