auric_runtime/routing/
router.rs1use super::RouteDef;
2use std::sync::Arc;
3use web_sys::window;
4
5#[derive(Clone)]
6pub struct Router {
7 #[allow(unused)]
8 router: Arc<actix_router::Router<RouteDef>>,
9}
10
11impl Default for Router {
12 fn default() -> Self {
13 let builder = actix_router::Router::build();
14 let router = Arc::new(builder.finish());
15 Self { router }
16 }
17}
18
19impl Router {
20 pub fn new() -> Self {
21 Self::default()
22 }
23
24 pub fn init(&self) -> anyhow::Result<()> {
25 let _href = window()
27 .and_then(|win| win.location().href().ok())
28 .expect("Could not access window location");
29 web_sys::console::log_1(&"Initialized router".into());
36 Ok(())
37 }
38}