use axum::{Router, response::{Response, Redirect, IntoResponse}, routing::get}; use crate::{types::{extract::AuthorizedUser, response::ResponseCode}, console}; async fn root(user: Option) -> Response { if user.is_some() { Redirect::to("/home").into_response() } else { Redirect::to("/login").into_response() } } async fn login(user: Option) -> Response { if user.is_some() { Redirect::to("/home").into_response() } else { ResponseCode::Success.file("/login.html").await } } async fn home(user: Option) -> Response { if user.is_none() { Redirect::to("/login").into_response() } else { ResponseCode::Success.file("/home.html").await } } async fn people(user: Option) -> Response { if user.is_none() { Redirect::to("/login").into_response() } else { ResponseCode::Success.file("/people.html").await } } async fn profile(user: Option) -> Response { if user.is_none() { Redirect::to("/login").into_response() } else { ResponseCode::Success.file("/profile.html").await } } async fn console() -> Response { console::generate().await } async fn wordpress() -> Response { ResponseCode::ImATeapot.text("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("/console", get(console)) .route("/wp-admin", get(wordpress)) }