blob: a716af22e7b74c020a9ba49a221453bbeb2c2f0f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
use axum::{response::IntoResponse, routing::get, Router};
use sqlx::sqlite::SqlitePool;
use crate::login::repo::logins::Login;
pub fn router() -> Router<SqlitePool> {
Router::new().route("/", get(index))
}
async fn index(login: Option<Login>) -> impl IntoResponse {
templates::index(login)
}
mod templates {
use maud::{html, Markup, DOCTYPE};
use crate::login::repo::logins::Login;
pub fn index(login: Option<Login>) -> 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) }
}
}
}
}
|