rustack_sts_http/
dispatch.rs1use std::{future::Future, pin::Pin};
4
5use bytes::Bytes;
6use rustack_sts_model::{error::StsError, operations::StsOperation};
7
8use crate::body::StsResponseBody;
9
10pub trait StsHandler: Send + Sync + 'static {
15 fn handle_operation(
17 &self,
18 op: StsOperation,
19 body: Bytes,
20 caller_access_key: Option<String>,
21 request_id: &str,
22 ) -> Pin<Box<dyn Future<Output = Result<http::Response<StsResponseBody>, StsError>> + Send>>;
23}
24
25pub async fn dispatch_operation<H: StsHandler>(
27 handler: &H,
28 op: StsOperation,
29 body: Bytes,
30 caller_access_key: Option<String>,
31 request_id: &str,
32) -> Result<http::Response<StsResponseBody>, StsError> {
33 tracing::debug!(operation = %op, "dispatching STS operation");
34 handler
35 .handle_operation(op, body, caller_access_key, request_id)
36 .await
37}