sfr_server/handler/
home.rs1use crate::response::home::GetHomeResponse;
4use crate::ResponseError;
5
6pub trait HomeHandlerTrait: Send + Sync {
8 fn handle_home(
10 &self,
11 ) -> impl std::future::Future<Output = Result<Vec<u8>, ResponseError>> + Send;
12}
13
14#[derive(Clone)]
16pub(crate) struct HomeHandler<T>(T)
17where
18 T: HomeHandlerTrait;
19
20impl<T> HomeHandler<T>
21where
22 T: HomeHandlerTrait,
23{
24 pub fn new(inner: T) -> Self {
26 Self(inner)
27 }
28
29 pub fn handle<'a>(
31 &'a self,
32 ) -> impl std::future::Future<Output = Result<impl axum::response::IntoResponse, ResponseError>>
33 + Send
34 + 'a {
35 tracing::info!("get home: start to process");
36
37 async move {
38 let resp = self.0.handle_home().await?;
39
40 Ok(GetHomeResponse::new(resp))
41 }
42 }
43}