Basic yew router working now

This commit is contained in:
Marko Korhonen 2020-04-25 11:08:51 +03:00
parent a42d8557a8
commit bd2c70fcfb
No known key found for this signature in database
GPG key ID: 911B85FBC6003FE5

View file

@ -11,11 +11,11 @@ struct App {}
#[derive(Debug, Switch, Clone)]
enum AppRoute {
#[to = "/"]
Root,
#[to = "/login"]
Login,
PageNotFound(Permissive<String>),
#[to = "/"]
Root,
}
impl Component for App {
@ -42,11 +42,11 @@ impl Component for App {
render = Router::render(|switch: AppRoute| {
match switch {
AppRoute::Login => html!{<LoginComponent />},
AppRoute::PageNotFound(Permissive(None)) => html!{"Page not found"},
AppRoute::PageNotFound(Permissive(Some(missed_route))) => html!{format!("Page '{}' not found", missed_route)},
AppRoute::Root => {
html!{"hello there!"}
},
AppRoute::PageNotFound(Permissive(None)) => html!{"Page not found"},
AppRoute::PageNotFound(Permissive(Some(missed_route))) => html!{format!("Page '{}' not found", missed_route)}
}
})
redirect = Router::redirect(|route: Route| {