pub struct StaticConfig {
pub body: String,
pub raw: bool,
pub metadata: HashMap<String, String>,
}Expand description
Configuration for the static endpoint.
Accepts either a bare string (the response body, JSON-encoded for backward compatibility) or a map for full control:
# bare string -> body is JSON-encoded ("Hello" comes back quoted)
static: "Hello, World!"
# map form -> raw body + custom metadata (HTTP maps metadata to headers)
static:
body: "Hello, World!"
raw: true
metadata:
content-type: "text/plain"
server: "mq-bridge"When raw is true the body is sent verbatim; otherwise it is JSON-encoded as
a string. Every entry in metadata is attached to the produced message; when
this endpoint feeds an HTTP response, those entries become response headers
(e.g. content-type), otherwise they are ordinary message metadata.
The body supports ${…} placeholders (compiled once at startup): request
fields ${payload:a.b} / ${metadata:key} / ${message:id}, generators
${gen:uuid|now|timestamp|counter|random(1,100)}, and ${env:VAR}. When the
content-type metadata is a JSON type, interpolated request values are
JSON-escaped by default; append | raw to splice verbatim, and write $${…}
to emit a literal ${…}. See crate::support::interpolation for the full reference.
Fields§
§body: StringThe static response body.
raw: boolSend the body verbatim instead of JSON-encoding it as a string.
metadata: HashMap<String, String>Extra metadata entries attached to the produced message.
Trait Implementations§
Source§impl Clone for StaticConfig
impl Clone for StaticConfig
Source§fn clone(&self) -> StaticConfig
fn clone(&self) -> StaticConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more