Router
Routes events to different transformer chains based on ingest metadata. The router inspects context.ingest (set by the source) and branches to the first matching route.
Setup
- Integrated
- Bundled
Install the package:
Loading...
Configure in your code:
Loading...
How it works
- A server source (express, fetch) sets
context.ingestwith request metadata (path, method, headers, etc.) - The router evaluates routes in order — first match wins
- On match, the event resets to
{}and branches to the matched transformer chain - The downstream parser builds a proper event from
context.ingest - If no route matches and there's no wildcard, the event passes through unchanged
Route configuration
Each route has a match expression and a next target:
Loading...
| Option | Type | Description |
|---|---|---|
match | MatchExpression | '*' | Condition to evaluate against ingest, or '*' wildcard |
next | string | string[] | Transformer chain(s) to branch to on match |
Match operators
| Operator | Description | Example |
|---|---|---|
eq | Exact string match | { key: 'method', operator: 'eq', value: 'POST' } |
prefix | Starts with | { key: 'path', operator: 'prefix', value: '/api' } |
suffix | Ends with | { key: 'path', operator: 'suffix', value: '.json' } |
contains | Substring match | { key: 'path', operator: 'contains', value: 'collect' } |
regex | Regular expression | { key: 'path', operator: 'regex', value: '^/v\\d+/' } |
gt | Greater than (numeric) | { key: 'contentLength', operator: 'gt', value: '1000' } |
lt | Less than (numeric) | { key: 'contentLength', operator: 'lt', value: '5000' } |
exists | Key is present | { key: 'authorization', operator: 'exists', value: '' } |
Every condition supports negation with not: true:
Loading...
Logical combinators
Combine conditions with and / or, nestable to any depth:
Loading...
Loading...
Deeply nested example
Loading...
Examples
Multi-path server endpoint
Route different vendor payloads through dedicated parsers:
Loading...
Branching to multiple chains
A route can target multiple chains at once:
Loading...
Performance
Routes are compiled to closures at init time. Regular expressions are compiled once and reused on every request. Runtime evaluation is a simple loop with short-circuit logic for and/or combinators.
Next steps
- Validator - Validate events after routing
- Create your own - Build custom transformers
💡 Need Professional Support?
Need professional support with your walkerOS implementation? Check out our services.