Candle Documentation

HTTP Client Components

Configuration References

HTTP Components are a special type of component that allow you to define operations whose implementation is backed by an HTTP request. An HTTP operation takes inputs like any other operation and uses those inputs to build up URL paths, query parameters, and request body data.

Global configuration

See the HTTP Client component documentation for more details. Important options include:

resource

HTTP Client Operations require a url resource to use as the base url for operation requests.

codec

The codec defines how the request and response bodies should be encoded and decoded. See the codec documentation for allowed values.

Per-operation configuration

See the HTTP Client operation definition documentation for more details.

inputs

The inputs to HTTP Client operations are defined by the HTTP Client operation definition configurations.

outputs (unconfigurable)

  • response - The response object (status, headers, et al) returned by the HTTP request.
  • body - Bytes or JSON dependending on the codec

Example

Example showing how to use the HTTP Client component to make HTTP requests from Wick.

Every component starts off with the common Component kind and an optional name.

kind: wick/component@v1
name: http_client_example

This example defines one operation, httpbin_get, that uses HTTPBIN to echo our query parameters back to us. Notice how we use Liquid syntax in our path to dynamically build up the URL.

operations:
- inputs:
  - name: message
    type: string
  name: httpbin_get
  path: /get?msg={{message}}

The full configuration is located at examples/components/http-client.wick.

Running on the CLI with wick invoke

Run this component on the command line by cloning the wick repository and using wick invoke.

Note: Use cargo run -p wick-cli -- invoke to run wick from source.

Clone the repository with

git clone https://github.com/candlecorp/wick && cd wick

Notice: the arguments to the operation come after the --.

Invoke the operation httpbin_get with the following command:

wick invoke examples/components/http-client.wick httpbin_get -- --message=[...] 

Complete Example

The full example configuration is included below,

kind: wick/component@v1
name: http_client_example
metadata:
  version: 0.0.1
  description: Example showing how to use the HTTP Client component to make HTTP requests from Wick.
  licenses:
    - Apache-2.0
resources:
  - name: BASEURL
    resource:
      kind: wick/resource/url@v1
      url: http://{{ ctx.env.HTTPBIN }}
component:
  kind: wick/component/http@v1
  resource: BASEURL
  operations:
    - name: httpbin_get
      inputs:
        - name: message
          type: string
      path: /get?msg={{message}}