pub struct TransformMiddleware {
pub mapping: HashMap<String, MappingRule>,
pub schema: Option<Value>,
pub schema_file: Option<String>,
pub coerce: bool,
pub apply_defaults: bool,
pub on_error: TransformErrorPolicy,
}Expand description
JSON transform middleware configuration.
Reshapes JSON payloads declaratively, in two stages over a single parse: field
mapping (rename/move/nest), then schema (type coercion, defaults, validation).
Either stage may be omitted; with neither configured the message passes through
untouched and is never parsed.
On an output endpoint a rejected message becomes a non-retryable failure, so a dlq
middleware listed after this one captures it (publisher middlewares are wrapped in
list order, so the last entry is the outermost layer). On an input endpoint a rejected
message is dropped from the batch and acknowledged, which is how invalid input is kept
out of the route.
Fields§
§mapping: HashMap<String, MappingRule>Output field name -> source path (e.g. firstName: "$.first_name"). Dots nest the output.
schema: Option<Value>Inline JSON Schema subset (type, properties, required, default, items, nullable, enum).
schema_file: Option<String>Path to a JSON Schema file. Read once at startup; never re-read per message.
coerce: boolCoerce safely convertible types (e.g. "42" -> 42) instead of rejecting. Defaults to true.
apply_defaults: boolInsert default values from the schema for missing fields. Defaults to true.
on_error: TransformErrorPolicyWhat to do with a message that fails to transform. Defaults to reject.
Trait Implementations§
Source§impl Clone for TransformMiddleware
impl Clone for TransformMiddleware
Source§fn clone(&self) -> TransformMiddleware
fn clone(&self) -> TransformMiddleware
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more