use axum::{response::IntoResponse, routing::get, Router}; use sqlx::sqlite::SqlitePool; use crate::login::repo::logins::Login; pub fn router() -> Router { Router::new().route("/", get(index)) } async fn index(login: Option) -> impl IntoResponse { templates::index(login) } mod templates { use maud::{html, Markup, DOCTYPE}; use crate::login::repo::logins::Login; pub fn index(login: Option) -> Markup { html! { (DOCTYPE) head { title { "hi" } } body { @match login { None => { (login_form()) } Some(login) => { (logout_form(&login.name)) } } } } } fn login_form() -> Markup { html! { form action="/login" method="post" { label { "name" input name="name" type="text" {} } label { "password" input name="password" type="password" {} } button { "hi" } } } } fn logout_form(name: &str) -> Markup { html! { form action="/logout" method="post" { button { "bye, " (name) } } } } }