diff --git a/src/main.rs b/src/main.rs index 13eb6ee..483d9a8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -66,7 +66,7 @@ async fn main() -> anyhow::Result<()> { .nest("/api", routes::mk_api_routes(config.clone())) // HTMX ui component endpoints .nest("/ui", routes::mk_ui_routes(config.clone())) - .route("/", get(routes::index).with_state(config.clone())) + .route("/", get(routes::index).with_state(State(config.clone()))) .layer(TraceLayer::new_for_http()) .with_state(State(config.clone())); let socket_addr = args.listen.unwrap_or("127.0.0.1:3000".to_string()); diff --git a/src/routes.rs b/src/routes.rs index 949a593..3399d48 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -58,11 +58,20 @@ pub fn mk_api_routes(config: Arc>) -> Router { ) } -pub fn mk_ui_routes(config: Arc>) -> Router { - Router::new() +pub async fn dash_ui(State(config): State, Path(idx): Path) -> Markup { + html!( + "TODO(jwall): Fill this in" + ) } -pub async fn index(State(config): Config) -> Markup { +pub fn mk_ui_routes(config: Arc>) -> Router { + Router::new().route( + "/dash/:idx", + get(dash_ui).with_state(State(config)) + ) +} + +pub async fn index(State(config): State) -> Markup { html! { html { head { @@ -76,7 +85,7 @@ pub async fn index(State(config): Config) -> Markup { } } -pub async fn app(State(config): Config) -> Markup { +pub async fn app(State(config): State) -> Markup { let titles = config .iter() .map(|d| d.title.clone()) @@ -87,7 +96,7 @@ pub async fn app(State(config): Config) -> Markup { // Header menu ul { @for title in &titles { - li hx-get=(format!("/ui/dash/{}/", title.0)) hx-target="#dashboard" { (title.1) } + li hx-get=(format!("/ui/dash/{}", title.0)) hx-target="#dashboard" { (title.1) } } } // dashboard display