Skip to main content

Router

Server Source code Package

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

Install the package:

Loading...

Configure in your code:

Loading...

How it works

  1. A server source (express, fetch) sets context.ingest with request metadata (path, method, headers, etc.)
  2. The router evaluates routes in order — first match wins
  3. On match, the event resets to {} and branches to the matched transformer chain
  4. The downstream parser builds a proper event from context.ingest
  5. 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...
OptionTypeDescription
matchMatchExpression | '*'Condition to evaluate against ingest, or '*' wildcard
nextstring | string[]Transformer chain(s) to branch to on match

Match operators

OperatorDescriptionExample
eqExact string match{ key: 'method', operator: 'eq', value: 'POST' }
prefixStarts with{ key: 'path', operator: 'prefix', value: '/api' }
suffixEnds with{ key: 'path', operator: 'suffix', value: '.json' }
containsSubstring match{ key: 'path', operator: 'contains', value: 'collect' }
regexRegular expression{ key: 'path', operator: 'regex', value: '^/v\\d+/' }
gtGreater than (numeric){ key: 'contentLength', operator: 'gt', value: '1000' }
ltLess than (numeric){ key: 'contentLength', operator: 'lt', value: '5000' }
existsKey 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

💡 Need Professional Support?
Need professional support with your walkerOS implementation? Check out our services.