RemoveHeaders¶
RemoveHeaders strips all message headers matching a glob pattern, with an optional whitelist of header names to preserve. It complements RemoveHeader (single header, in transform) and is typically used to scrub internal/transport headers before publishing a message to an outbound endpoint.
Processors in this file¶
NewRemoveHeaders¶
YAML form:
| Field | Type | Default | Description |
|---|---|---|---|
pattern |
string | required | Glob pattern (Go filepath.Match syntax). Common patterns: Helix*, X-Internal-*, temp.*. |
except |
list of strings | empty | Header names to keep even if they match pattern. |
Constructor: NewRemoveHeaders(pattern string, except ...string) *RemoveHeaders.
How it works:
- Iterates all headers on the
In()message. - Skips any header whose name is in the
exceptset. - Tests the remaining names against
patternwithfilepath.Match. Matches are removed. - Invalid glob patterns are silently skipped (the processor never errors), so a malformed pattern is a no-op rather than data loss.
Pitfalls:
- The Go glob syntax is not regex.
*matches any sequence except path separators; there is no*?lazy quantifier. UseH*notH.*. - Pattern matching is case-sensitive on header names.
- To remove a single header use the
remove-header:keyword (seetransform).
Examples¶
workflows:
- id: scrub-internals-before-send
trigger: { uri: direct://outbound }
steps:
- remove-headers:
pattern: "Helix*"
except: ["HelixWorkflowId", "HelixStepId"]
- target: kafka://outbound-events
Source¶
pkg/processor/remove_headers.go