pub trait IntoHandler<T>:
Clone
+ Send
+ Sync
+ 'static {
// Required method
fn call<'async_trait>(
self,
req: Request,
) -> Pin<Box<dyn Future<Output = Result<Response>> + Send + 'async_trait>>
where Self: 'async_trait;
}Expand description
Trait for converting functions into handlers.
This trait is similar to UniversalHandler but specifically for handlers
that return Result<Response>. It provides a bridge between regular async
functions and the handler system.
The type parameter T represents the extractor types used by the handler.
§Type Parameter
T- Tuple representing the extractor types
Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementors§
impl<F, Fut> IntoHandler<(RawRequest,)> for F
Implementation for functions that take RawRequest directly.
This allows handlers to receive the complete Request object without going through the extraction system.
impl<F, Fut> IntoHandler<()> for F
Implementation for functions with no extractors that just return Response.
This allows simple functions that don’t need request data to be used as handlers.
§Examples
use ignitia::{Response, Result};
// This function implements IntoHandler<()>
async fn health_check() -> Result<Response> {
Ok(Response::json(serde_json::json!({
"status": "healthy",
"timestamp": chrono::Utc::now().to_rfc3339()
}))?)
}