use crate::response::home::GetHomeResponse;
use crate::ResponseError;
use axum::async_trait;
#[async_trait]
pub trait HomeHandlerTrait: Send + Sync {
async fn handle_home(&self) -> Result<Vec<u8>, ResponseError>;
}
#[derive(Clone)]
pub(crate) struct HomeHandler<T>(T)
where
T: HomeHandlerTrait;
impl<T> HomeHandler<T>
where
T: HomeHandlerTrait,
{
pub fn new(inner: T) -> Self {
Self(inner)
}
pub async fn handle(&self) -> Result<impl axum::response::IntoResponse, ResponseError> {
tracing::info!("get home: start to process");
let resp = self.0.handle_home().await?;
Ok(GetHomeResponse::new(resp))
}
}