#[doc(inline)]
pub use self::{actor::Server, context::ServerContext};
mod actor;
mod context;
use crate::config::Scope;
use crate::traits::AxumState;
use axum::Router;
use tower_http::{services::ServeDir, trace::TraceLayer};
fn router<S>(scope: &Scope) -> Router<S>
where
S: AxumState,
{
let tgt = scope.as_path();
Router::new()
.merge(serve_dir("/", tgt))
.layer(TraceLayer::new_for_http())
.with_state(AppState::new())
}
fn serve_dir<S, P>(path: &str, workdir: P) -> Router<S>
where
P: AsRef<std::path::Path>,
S: Clone + Send + Sync + 'static,
{
Router::new().nest_service(path, ServeDir::new(workdir))
}
#[derive(
Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, serde::Deserialize, serde::Serialize,
)]
pub struct AppState {}
impl AppState {
pub fn new() -> Self {
Self {}
}
}
unsafe impl Send for AppState {}
unsafe impl Sync for AppState {}