sfr_server/handler/
home.rs1use crate::response::home::GetHomeResponse;
4use crate::ResponseError;
5use axum::async_trait;
6
7#[async_trait]
9pub trait HomeHandlerTrait: Send + Sync {
10 async fn handle_home(&self) -> Result<Vec<u8>, ResponseError>;
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 async fn handle(&self) -> Result<impl axum::response::IntoResponse, ResponseError> {
31 tracing::info!("get home: start to process");
32
33 let resp = self.0.handle_home().await?;
34
35 Ok(GetHomeResponse::new(resp))
36 }
37}