Run http-request in Direktiv as a function
functions: - id: http-request image: gcr.io/direktiv/functions/http-request:1.0 type: knative-workflow
- id: http-request type: action action: function: http-request input: debug: true url: 'https://www.direktiv.io' params: hello: world hello1: world2
- id: http-request type: action action: function: http-request input: url: 'https://www.direktiv.io' method: POST headers: header1: value1 header2: value2
- id: http-request type: action action: function: http-request input: url: 'https://www.direktiv.io' method: POST content: value: hello: world my: data
- id: http-request type: action action: function: http-request input: url: 'https://www.direktiv.io' method: POST content: kind: string value: 'This is the payload'
- id: http-request type: action action: function: http-request input: url: 'https://www.direktiv.io/doesnotexist' error200: true catch: - error: "*"
No secrets required
Type | Description |
---|---|
io.direktiv.command.error | Command execution failed |
io.direktiv.output.error | Template error for output generation of the service |
io.direktiv.ri.error | Can not create information object from request |
Name | Type | Default | Description | Example |
---|---|---|---|---|
url | string | URL for the request. | http://www.direktiv.io | |
method | string | HTTP method. Defaults to GET. | POST | |
headers | map of string | List of key/values send as headers with the request. | ||
params | map of string | List of key/values appended to URL as query parameters. | ||
username | string | If username and password are set, it will be used for basic authenitcation for the request. | myuser | |
password | string | If username and password are set, it will be used for basic authenitcation for the request. | mypassword | |
insecure | boolean | Skips the verification the server certificate chain and host name. | true | |
error200 | boolean | If set to true responses with status above 299 will be treated as errors. | true | |
debug | boolean | Prints the full URL and headers to logs. | true | |
content | object |
Defines the payload of the request. The kind
value can have three different values:
Name | Type | Default | Description | Example |
---|---|---|---|---|
kind | string | json | Kind of data | |
value | interface{} | Value depends on kind value. |
{ "code": 200, "headers": { "Access-Control-Allow-Origin": "*", "Content-Type": "text/html" }, "result": "KXx8T2JqZWN0LmR...", "success": true }