blob: 749a686520d47586703590ee323fdff35d8ae541 (
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
58
|
use axum::{Router, response::{Response, Redirect, IntoResponse}, routing::get};
use crate::types::{extract::AuthorizedUser, response::ResponseCode};
async fn root(user: Option<AuthorizedUser>) -> Response {
println!("{}", user.is_some());
if user.is_some() {
return Redirect::to("/home").into_response()
} else {
return Redirect::to("/login").into_response()
}
}
async fn login(user: Option<AuthorizedUser>) -> Response {
if user.is_some() {
return Redirect::to("/home").into_response()
} else {
return ResponseCode::Success.file("/login.html").await.unwrap()
}
}
async fn home(user: Option<AuthorizedUser>) -> Response {
if user.is_none() {
return Redirect::to("/login").into_response()
} else {
return ResponseCode::Success.file("/home.html").await.unwrap()
}
}
async fn people(user: Option<AuthorizedUser>) -> Response {
if user.is_none() {
return Redirect::to("/login").into_response()
} else {
return ResponseCode::Success.file("/people.html").await.unwrap()
}
}
async fn profile(user: Option<AuthorizedUser>) -> Response {
if user.is_none() {
return Redirect::to("/login").into_response()
} else {
return ResponseCode::Success.file("/profile.html").await.unwrap()
}
}
async fn wordpress() -> Response {
ResponseCode::ImATeapot.msg("Hello i am a teapot owo")
}
pub fn router() -> Router {
Router::new()
.route("/", get(root))
.route("/login", get(login))
.route("/home", get(home))
.route("/people", get(people))
.route("/profile", get(profile))
.route("/wp-admin", get(wordpress))
}
|