pub struct HttpConfig {
pub method: String,
pub url: String,
pub headers: Vec<(String, String)>,
pub body: Option<Value>,
pub timeout_secs: Option<u64>,
pub allow_failure: bool,
pub retry: Option<RetryPolicy>,
pub trace_context: Option<WorkflowTraceContext>,
pub allowed_hosts: Vec<String>,
}Expand description
Serializable configuration for an HTTP step.
§Examples
use ironflow_engine::config::HttpConfig;
let config = HttpConfig::get("https://api.example.com/health");Fields§
§method: StringHTTP method (GET, POST, PUT, PATCH, DELETE).
url: StringRequest URL.
headers: Vec<(String, String)>Request headers.
body: Option<Value>Request body as JSON.
timeout_secs: Option<u64>Timeout in seconds (default: 30).
allow_failure: boolWhen true, a failure of this step does not fail the run.
retry: Option<RetryPolicy>Optional step-level retry policy.
trace_context: Option<WorkflowTraceContext>Optional W3C trace context for distributed tracing propagation.
allowed_hosts: Vec<String>Hosts this step may reach even when they are internal. See
allow_host.
Implementations§
Source§impl HttpConfig
impl HttpConfig
Sourcepub fn get(url: &str) -> Self
pub fn get(url: &str) -> Self
Create a GET request config.
§Examples
use ironflow_engine::config::HttpConfig;
let config = HttpConfig::get("https://example.com");
assert_eq!(config.method, "GET");Sourcepub fn timeout_secs(self, secs: u64) -> Self
pub fn timeout_secs(self, secs: u64) -> Self
Set the timeout in seconds.
Sourcepub fn allow_failure(self) -> Self
pub fn allow_failure(self) -> Self
Mark this step as allowed to fail without stopping the run.
§Examples
use ironflow_engine::config::HttpConfig;
let config = HttpConfig::get("https://example.com").allow_failure();
assert!(config.allow_failure);Sourcepub fn retry_policy(self, policy: RetryPolicy) -> Self
pub fn retry_policy(self, policy: RetryPolicy) -> Self
Set a step-level retry policy.
§Examples
use ironflow_core::retry::RetryPolicy;
use ironflow_engine::config::HttpConfig;
let config = HttpConfig::get("https://api.example.com")
.retry_policy(RetryPolicy::new(5));
assert!(config.retry.is_some());Sourcepub fn allow_host(self, host: &str) -> Self
pub fn allow_host(self, host: &str) -> Self
Let this step reach host even when it is, or resolves to, a private, loopback,
link-local or cloud metadata address.
Without it, the step fails before anything is sent. Hosts allowed for the whole
deployment go in the worker’s IRONFLOW_HTTP_ALLOWED_HOSTS environment variable
instead. See Http::allow_host.
§Examples
use ironflow_engine::config::HttpConfig;
let config = HttpConfig::get("http://billing.internal:8080/invoices")
.allow_host("billing.internal");
assert_eq!(config.allowed_hosts, ["billing.internal"]);