Candle Documentation

Raw Router

Example showing how to use the Raw Router to delegate an http request to any arbitrary Wick Component.

This app configuration starts off with the common Application kind and a name field.

kind: wick/app@v1
name: serve_http_component

Note: All HTTP routers must be configured with a path that acts as a simple filter to determine which router to execute. Routers are executed in top-down order. A router configured with path: "/" will match all traffic so should be defined at the end of the router configuration.

Raw Routers delegate an HTTP request directly to a wick component. In addition to the router path configuration, raw routers require a reference to an operation that will handle the request.

- codec: Json
  kind: wick/router/raw@v1
  operation: test_component::http_handler
  path: /

Operations can be defined inline or referenced by name from a previously imported component. The operation value above comes from a previously imported import block:

- component:
    kind: wick/component/manifest@v1
    ref: ../../crates/integration/test-http-trigger-component/component.yaml
  name: test_component

The full configuration is located at examples/http/raw-router.wick. Run this application locally by cloning the wick repository and using wick run (or cargo run -p wick-cli -- run to run from source)

git clone && cd wick
wick run examples/http/raw-router.wick

Complete Example

Note: Examples may require environment variables and execution from within the wick project’s root to access any local files.

The full example configuration is included below,

kind: wick/app@v1
name: serve_http_component
  description: Example showing how to use the Raw Router to delegate an http request to any arbitrary Wick Component.
  version: 0.0.1
    - 'Wick Maintainers'
    - 'Candle Corporation'
    - Apache-2.0
  - name: http
      kind: wick/resource/tcpport@v1
      port: '8999'
  - name: test_component
      kind: wick/component/manifest@v1
      ref: ../../crates/integration/test-http-trigger-component/component.yaml
  - kind: wick/trigger/http@v1
    resource: http
      - kind: wick/router/raw@v1
        path: /
        codec: Json
        operation: test_component::http_handler