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 withpath: "/"
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.
routers:
- 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:
import:
- 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 https://github.com/candlecorp/wick && 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
metadata:
description: Example showing how to use the Raw Router to delegate an http request to any arbitrary Wick Component.
version: 0.0.1
authors:
- 'Wick Maintainers'
vendors:
- 'Candle Corporation'
licenses:
- Apache-2.0
resources:
- name: http
resource:
kind: wick/resource/tcpport@v1
port: '8999'
address: 0.0.0.0
import:
- name: test_component
component:
kind: wick/component/manifest@v1
ref: ../../crates/integration/test-http-trigger-component/component.yaml
triggers:
- kind: wick/trigger/http@v1
resource: http
routers:
- kind: wick/router/raw@v1
path: /
codec: Json
operation: test_component::http_handler