Skip to main content

ironflow_engine/context/steps/
http.rs

1//! HTTP step for [`WorkflowContext`].
2
3use ironflow_store::models::StepKind;
4
5use crate::config::{HttpConfig, StepConfig};
6use crate::context::WorkflowContext;
7use crate::error::EngineError;
8use crate::executor::StepOutput;
9
10impl WorkflowContext {
11    /// Execute an HTTP step.
12    ///
13    /// # Errors
14    ///
15    /// Returns [`EngineError`] if the request fails or the store errors.
16    ///
17    /// # Examples
18    ///
19    /// ```no_run
20    /// use ironflow_engine::context::WorkflowContext;
21    /// use ironflow_engine::config::HttpConfig;
22    /// use ironflow_engine::error::EngineError;
23    ///
24    /// # async fn example(ctx: &mut WorkflowContext) -> Result<(), EngineError> {
25    /// let resp = ctx.http("health", HttpConfig::get("https://api.example.com/health")).await?;
26    /// println!("status: {:?}, body: {}", resp.status(), resp.body());
27    /// # Ok(())
28    /// # }
29    /// ```
30    pub async fn http(
31        &mut self,
32        name: &str,
33        config: HttpConfig,
34    ) -> Result<StepOutput, EngineError> {
35        self.execute_step(name, StepKind::Http, StepConfig::Http(config))
36            .await
37    }
38}