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{})
| 39 | // HTTPGetJSON performs a GET request and unmarshals the JSON response. |
| 40 | // Only hostnames configured in the policy engine's AllowedHosts are accessible. |
| 41 | func 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. |