http

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

README

HTTP

http.fetch

This action fetches data from the specified URL using the specified HTTP method and returns the result.

Arguments

Example policy:

run contains res if {
  res := {
    id: "your-action",
    uses: "http.fetch",
    args: {
      "method": "GET",
      "url": "https://api.example.com/data",
      "header": {
        "Authorization": "Bearer " + input.env.API_TOKEN,
      },
    },
  },
}
  • method (string, required): Specifies the HTTP method to use for the request (e.g., "GET", "POST", "PUT", "DELETE").
  • url (string, required): Specifies the URL to fetch the data from.
  • header (map of strings, optional): Specifies the HTTP headers to include in the request.
  • data (string, optional): Specifies the request body to include in the request (for methods like "POST" and "PUT").
Response

The response depends on the Content-Type of the HTTP response. The following content types are supported:

  • application/json: The response body will be parsed as JSON and returned as an object.
  • application/octet-stream: The response body will be returned as a byte array.
  • Other content types: The response body will be returned as a string.

In case of an error while making the HTTP request or processing the response, an error will be returned.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fetch

func Fetch(ctx context.Context, _ model.Alert, args model.ActionArgs) (any, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL