framework_web_axum/
lib.rs1mod context;
2mod cors;
3mod dispatch;
4mod router;
5mod server;
6
7pub use context::{AxumContext, scope_axum, use_axum};
8pub use cors::AxumCors;
9pub use router::{WebRouteResultFuture, WebRouteWrapper, WebRouter};
10pub use server::{AxumBuilder, AxumServer, axum_builder};
11
12use crate::dispatch::{AxumState, dispatch};
13use axum::Router;
14use axum::routing::any;
15use framework_web::WebContext;
16use std::sync::Arc;
17
18pub type AxumCorsFn = Arc<dyn Fn(&WebContext) -> AxumCors + Send + Sync>;
20
21pub fn build_router(wrapper: Option<WebRouteWrapper>) -> WebRouter {
23 WebRouter::new(wrapper)
24}
25
26pub(crate) fn build_router_with(
28 router: Arc<WebRouter>,
29 context: AxumContext,
30 cors: AxumCorsFn,
31) -> Router {
32 Router::new().fallback(any(dispatch)).with_state(AxumState {
33 router,
34 context,
35 cors,
36 })
37}