request

command module
v0.0.0-...-8835833 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

README


{ "image": "direktiv/request", "desc": "Perform a basic HTTP/S request." }

Request

Perform a basic HTTP/S request.

Direktiv

An example workflow of using the container in a workflow on Direktiv.

id: request
functions:
- id: myrequest
  type: reusable
  image: direktiv/request:v1
description: "send a get request"
states:
- id: hello
  type: action
  action:
    function: myrequest
    input:
      method: "GET"
      url: "https://jsonplaceholder.typicode.com/posts"

Input

input:
  method: "GET"
  url: "https://direktiv.io"
  body:
    hello: "world"
  headers:
    "Content-Type": "application/json"
  params:
    Hello: "world"
  username: "test"
  password: "test2"
  insecureSkipVerify": false

NOTE: The method and url fields are mandatory.

Output

Output for a request that returns JSON.

{
    "return": {
        "body": {
            "hello": "world"
        },
        "headers":{
            "Age": 0
        },
        "status-code": 200,
        "status": "200 OK"
    }
}

Output for a request that isn't JSON.

{
    "return": {
        "data": "PGh0bWw+PGJvZHk+SGVsbG8gV29ybGQhPC9ib2R5PjwvaHRtbA==",
        "headers":{
            "Age": 0
        },
        "status-code": 200,
        "status": "200 OK"
    }
}

Error

In the case that an error is encountered, it will present in the following format:

{
    "errorCode": "com.%s.error",
    "errorMsg": "Something went wrong"
}

NOTE: %s indicating where in the container logic the request failed.

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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