pluginhttp

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2020 License: BSD-3-Clause Imports: 11 Imported by: 1

README

http Plugin

This plugin permorms an http request.

Configuration

Fields Description
url destination for the http call, including host, path and query params
method http method (GET/POST/PUT/DELETE)
body a string representing the payload to be sent with the request
headers a list of headers, represented as objects composed of name and value
timeout_seconds an unsigned int representing a custom HTTP client timeout in seconds
basic_auth a single object composed of user and password to enable HTTP basic auth
deny_redirects a boolean representing the policy of redirects
parameters a list of HTTP query parameters, represented as objects composed of key and value
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
    # mandatory, string
    method: POST
    # optional, string as uint16
    timeout_seconds: "5"
    # optional, object of user and password fields
    basic_auth:
      user: {{.config.basicAuth.user}}
      password: {{.config.basicAuth.password}}
    # optional, string as boolean
    deny_redirects: "false"
    # optional, array of key and value fields
    parameters:
    - key: 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 be retrieved from configstore and accessed through {{.config.[itemKey]}} rather than hardcoded in your template.

Documentation

Index

Constants

This section is empty.

Variables

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

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 BasicAuth added in v1.0.1

type BasicAuth struct {
	User     string `json:"user"`
	Password string `json:"password"`
}

BasicAuth represents a HTTP basic auth

type HTTPConfig

type HTTPConfig struct {
	URL            string      `json:"url"`
	Method         string      `json:"method"`
	Body           string      `json:"body,omitempty"`
	Headers        []Header    `json:"headers,omitempty"`
	TimeoutSeconds string      `json:"timeout_seconds,omitempty"`
	HTTPBasicAuth  BasicAuth   `json:"basic_auth,omitempty"`
	DenyRedirects  string      `json:"deny_redirects,omitempty"`
	Parameters     []Parameter `json:"parameters,omitempty"`
	TrimPrefix     string      `json:"trim_prefix,omitempty"`
}

HTTPConfig is the configuration needed to perform an HTTP call

type Header struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

Header represents an HTTP header

type Parameter added in v1.0.1

type Parameter struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

Parameter represents HTTP parameters

Jump to

Keyboard shortcuts

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