Skip to main content

HttpCallConfig

Struct HttpCallConfig 

Source
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: Template

Named 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: HttpMethod

HTTP 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: Template

Request timeout in milliseconds (default: 30000). Read it through Self::resolve_timeout_ms.

Implementations§

Source§

impl HttpCallConfig

Source

pub fn resolve_connector(&self, ctx: &TaskContext<'_>) -> Result<String>

Resolve the connector name for this message.

§Errors

As resolve_opt_string.

Source

pub fn resolve_path(&self, ctx: &TaskContext<'_>) -> Result<Option<String>>

Resolve the request path. Ok(None) when no path is configured.

§Errors

As resolve_opt_string.

Source

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.

Source

pub fn resolve_body(&self, ctx: &TaskContext<'_>) -> Result<Option<Value>>

Resolve the request body. Ok(None) when no body is configured.

§Errors

As Self::resolve_path.

Source

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.

Source

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.

Source

pub fn resolve_response_format( &self, ctx: &TaskContext<'_>, ) -> Result<Option<String>>

Resolve the response decoding name. Ok(None) when unset.

§Errors

As resolve_opt_string.

Source

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

Source§

fn clone(&self) -> HttpCallConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for HttpCallConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for HttpCallConfig

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.