pub struct HttpCallConfig {
pub connector: Template,
pub method: HttpMethod,
pub path: Option<Template>,
pub headers: HashMap<String, Template>,
pub body: Option<Template>,
pub body_format: Option<Template>,
pub response_path: Option<Template>,
pub response_format: Option<Template>,
pub timeout_ms: Template,
}Expand description
Configuration for the http_call integration function.
The actual HTTP implementation is provided by the service layer via AsyncFunctionHandler. This struct provides typed config validation and pre-compilation of JSONLogic expressions.
Unknown keys are rejected. A misspelled field previously parsed cleanly and
was discarded, so an http_call task could make its request and silently
throw the response away with no error at build time and none at dispatch.
Fields§
§connector: TemplateNamed connector reference (resolved by the service layer).
A JSONLogic expression, so one task can route by message content:
{"if": [{"var": "data.is_eu"}, "eu_gateway", "us_gateway"]}. The
static spelling "payments_api" is a literal and costs nothing. Read it
through Self::resolve_connector.
method: HttpMethodHTTP method
path: Option<Template>Request path, as a JSONLogic expression. Read it through
Self::resolve_path.
Back-compat: before 3.9 this was a static String with a separate
path_logic twin holding the expression, because a field could not be
both. It can now, so the two collapsed and path_logic is kept as an
alias so pre-3.9 definitions keep loading. Supplying both spellings is a
duplicate field error, not a precedence rule.
headers: HashMap<String, Template>Request headers. Each value is a JSONLogic expression, so a header can
carry a secret or a computed value:
{"Authorization": {"cat": ["Bearer ", {"secret": "api_token"}]}}.
A plain string value is a literal, so the static spelling is unchanged. Header names stay static — a name is not a computed value, and keeping them literal means no name can be swallowed as an operator.
body: Option<Template>Request body, as a JSONLogic expression. Read it through
Self::resolve_body.
Back-compat: as Self::path, body_logic is kept as an alias for the
pre-3.9 spelling.
A literal object body needs its keys escaped when they collide with an
operator name — {"$cat": …} for a body field actually called cat —
because the engine evaluates in templating mode. See Template.
body_format: Option<Template>How the resolved body becomes request bytes (e.g. "json", "form",
"text").
The value is data, not API surface: this crate does not validate or
interpret it — the service layer owns the value table, its default for
None, and the encoding behaviour. That split is deliberate: field
names are fixed here by deny_unknown_fields, but a service layer can
grow new values (say, "multipart") without touching this crate.
response_path: Option<Template>JSONPath/dot-path to extract from response and merge into context.
output is accepted as an alias, so a service layer can present one
destination-field name across its whole function catalogue. Supplying
both keys is a duplicate field error rather than a precedence rule.
response_format: Option<Template>How response bytes become the captured value (e.g. "json", "text").
As Self::body_format: data, not API surface — uninterpreted by this
crate, owned by the service layer.
timeout_ms: TemplateRequest timeout in milliseconds (default: 30000). Read it through
Self::resolve_timeout_ms.
Implementations§
Source§impl HttpCallConfig
impl HttpCallConfig
Sourcepub fn resolve_connector(&self, ctx: &TaskContext<'_>) -> Result<String>
pub fn resolve_connector(&self, ctx: &TaskContext<'_>) -> Result<String>
Sourcepub fn resolve_path(&self, ctx: &TaskContext<'_>) -> Result<Option<String>>
pub fn resolve_path(&self, ctx: &TaskContext<'_>) -> Result<Option<String>>
Sourcepub fn resolve_headers(
&self,
ctx: &TaskContext<'_>,
) -> Result<HashMap<String, String>>
pub fn resolve_headers( &self, ctx: &TaskContext<'_>, ) -> Result<HashMap<String, String>>
Resolve every request header for this message.
Header names are copied through unchanged; only the values are
expressions. A value that fails to evaluate fails the whole call rather
than sending the request with that header missing — a dropped
Authorization would otherwise surface as a confusing 401.
§Errors
As resolve_opt_string, for the first header value that fails.
Sourcepub fn resolve_body(&self, ctx: &TaskContext<'_>) -> Result<Option<Value>>
pub fn resolve_body(&self, ctx: &TaskContext<'_>) -> Result<Option<Value>>
Sourcepub fn resolve_body_format(
&self,
ctx: &TaskContext<'_>,
) -> Result<Option<String>>
pub fn resolve_body_format( &self, ctx: &TaskContext<'_>, ) -> Result<Option<String>>
Resolve the body encoding name. Ok(None) when unset — what that means
is the service layer’s call.
§Errors
As resolve_opt_string.
Sourcepub fn resolve_response_path(
&self,
ctx: &TaskContext<'_>,
) -> Result<Option<String>>
pub fn resolve_response_path( &self, ctx: &TaskContext<'_>, ) -> Result<Option<String>>
Resolve the dot-path the response is captured to. Ok(None) when unset.
§Errors
As resolve_opt_string.
Sourcepub fn resolve_response_format(
&self,
ctx: &TaskContext<'_>,
) -> Result<Option<String>>
pub fn resolve_response_format( &self, ctx: &TaskContext<'_>, ) -> Result<Option<String>>
Sourcepub fn resolve_timeout_ms(&self, ctx: &TaskContext<'_>) -> Result<u64>
pub fn resolve_timeout_ms(&self, ctx: &TaskContext<'_>) -> Result<u64>
Resolve the request timeout in milliseconds.
§Errors
As Template::resolve_u64 — a non-numeric result is a configuration
error, not something to silently default.
Trait Implementations§
Source§impl Clone for HttpCallConfig
impl Clone for HttpCallConfig
Source§fn clone(&self) -> HttpCallConfig
fn clone(&self) -> HttpCallConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more