Initial commit
This commit is contained in:
commit
bd9b07052b
81 changed files with 5516 additions and 0 deletions
35
http/src/server/mod.rs
Normal file
35
http/src/server/mod.rs
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
use eva::perfect_derive;
|
||||
|
||||
use viendesu_core::{
|
||||
errors::AuxResult,
|
||||
service::{Service, SessionMaker, SessionOf},
|
||||
};
|
||||
|
||||
pub mod config;
|
||||
|
||||
mod context;
|
||||
mod handler;
|
||||
mod request;
|
||||
mod response;
|
||||
|
||||
mod routes;
|
||||
|
||||
pub trait Types: Send + Sync + 'static {
|
||||
type Service: Service + Clone;
|
||||
}
|
||||
|
||||
pub fn make_router<T: Types>(service: T::Service) -> axum::Router {
|
||||
let scope = handler::RouterScope::root(State::<T> { service });
|
||||
routes::make(scope).into_axum()
|
||||
}
|
||||
|
||||
#[perfect_derive(Clone)]
|
||||
struct State<T: Types> {
|
||||
service: T::Service,
|
||||
}
|
||||
|
||||
impl<T: Types> State<T> {
|
||||
async fn make_session(&self) -> AuxResult<SessionOf<T::Service>> {
|
||||
self.service.make_session().await
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue