package
1.33.0-rc3
Repository: https://github.com/ovh/utask.git
Documentation: pkg.go.dev

# README

http Plugin

This plugin permorms an HTTP request.

Configuration

FieldsDescription
urldestination for the http call, including host, path and query params; this all-in-one field conflicts with host and path
hostdestination host for the http call; this field conflicts with the all-in-one field url
pathpath for the http call; to use jointly with the host field; this field conflicts with the all-in-one field url
methodhttp method (GET, POST, PUT, DELETE, PATCH)
bodya string representing the payload to be sent with the request
headersa list of headers, represented as (name, value) pairs
timeouttimeout expressed as a duration (e.g. 30s)
autha single object composed of either a basic or digest object with user and password fields to enable HTTP basic/digest auth, or a bearer field to enable Bearer Token Authorization, or a mutual_tls object to enable Mutual TLS authentication
follow_redirectif true (string) the plugin will follow up to 10 redirects (302, ...)
query_parametersa list of query parameters, represented as (name, value) pairs; these will appended the query parameters present in the url field; parameters can be repeated (in either url or query_parameters) which will produce e.g. ?param=value1&param=value2
trim_prefixprefix in the response that must be removed before unmarshalling (optional)
insecure_skip_verifyIf true (string), disables server's certificate chain and host verification.

Example

An action of type http requires the following kind of configuration:

action:
  type: http
  configuration:
    # mandatory, string
    url: http://example.org/user?lang=en
    # mandatory, string
    method: POST
    # optional, string as duration
    timeout: "5s"
    # optional, authentication you can use basic, digest or bearer auth
    auth:
      basic:
        user: {{.config.basicAuth.user}}
        password: {{.config.basicAuth.password}}
      digest:
        user: {{.config.digestAuth.user}}
        password: {{.config.digestAuth.password}}
      bearer: {{.config.auth.token}}
      mutual_tls:
        # a chain of certificates to identify the caller, first certificate in the chain is considered as the leaf, followed by intermediates
        client_cert: {{.config.mtls.clientCert}}
        # private key corresponding to the certificate
        client_key: {{.config.mtls.clientKey}}
    # optional, string as boolean
    follow_redirect: "true"
    # optional, defines additional root CAs to perform the call. can contains multiple CAs concatained together
    root_ca: {{.config.mtls.rootca}}
    # optional, string as boolean. indicates if server certificate must be validated or not.
    insecure_skip_verify: "false"
    # optional, array of name and value fields
    query_parameters:
    - name: foo
      value: bar
    # optional, array of name and value fields
    headers:
    - name:  x-request-id
      value: xxx-yyy-zzz
    # optional, string
    body: |
      {
        "name": "pablo"
      }

Requirements

None by default. Sensitive data should stored in the configuration and accessed through {{.config.[itemKey]}} rather than hardcoded in your template.

Resources

The http plugin declares automatically resources for its steps:

  • socket to rate-limit concurrent execution on the number of open outgoing sockets
  • url:hostname (where hostname is e.g. www.ovh.com) to rate-limit concurrent execution on a specific destination web-server/API

# Functions

ExecutorMetadata generates json schema to validate the metadata returned by the http executor.

# Constants

TimeoutDefault represents the default value that will be used for HTTP call, if not defined in configuration.

# Variables

the HTTP plugin performs an HTTP call.

# Structs

HTTPConfig is the configuration needed to perform an HTTP call.