pluginhttp

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2020 License: BSD-3-Clause Imports: 14 Imported by: 0

README

http Plugin

This plugin permorms an HTTP request.

Configuration

Fields Description
url destination for the http call, including host, path and query params; this all-in-one field conflicts with host and path
host destination host for the http call; this field conflicts with the all-in-one field url
path path for the http call; to use jointly with the host field; this field conflicts with the all-in-one field url
method http method (GET, POST, PUT, DELETE, PATCH)
body a string representing the payload to be sent with the request
headers a list of headers, represented as (name, value) pairs
timeout timeout expressed as a duration (e.g. 30s)
auth a single object composed of either a basic object with user and password fields to enable HTTP basic auth, or bearer field to enable Bearer Token Authorization
follow_redirect if true (string) the plugin will follow up to 10 redirects (302, ...)
query_parameters a 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_prefix prefix in the response that must be removed before unmarshalling (optional)

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 either basic or bearer auth
    auth:
      basic:
        user: {{.config.basicAuth.user}}
        password: {{.config.basicAuth.password}}
      bearer: {{.config.auth.token}}
    # optional, string as boolean
    follow_redirect: "true"
    # 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

Documentation

Index

Constants

View Source
const (
	// TimeoutDefault represents the default value that will be used for HTTP call, if not defined in configuration
	TimeoutDefault = "30s"
)

Variables

View Source
var (
	Plugin = taskplugin.New("http", "1.0", exec,
		taskplugin.WithConfig(validConfig, HTTPConfig{}),
		taskplugin.WithResources(resourceshttp),
	)
)

the HTTP plugin performs an HTTP call

Functions

func ExecutorMetadata

func ExecutorMetadata() string

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

Types

type HTTPConfig

type HTTPConfig struct {
	URL             string      `json:"url"`
	Host            string      `json:"host"`
	Path            string      `json:"path"`
	Method          string      `json:"method"`
	Body            string      `json:"body,omitempty"`
	Headers         []parameter `json:"headers,omitempty"`
	Timeout         string      `json:"timeout,omitempty"`
	Auth            auth        `json:"auth,omitempty"`
	FollowRedirect  string      `json:"follow_redirect,omitempty"`
	QueryParameters []parameter `json:"query_parameters,omitempty"`
	TrimPrefix      string      `json:"trim_prefix,omitempty"`
}

HTTPConfig is the configuration needed to perform an HTTP call

Jump to

Keyboard shortcuts

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