added nested routes, added separate config struct, among other items

This commit is contained in:
2024-09-24 20:26:15 -04:00
parent cf199ab48a
commit 845f058568
7 changed files with 164 additions and 23 deletions

View File

@ -1,15 +1,23 @@
use axum::{
http::StatusCode,
response::{Html, IntoResponse},
routing::get,
Router,
};
pub struct RootRoute;
impl RootRoute {
pub async fn root() -> Html<&'static str> {
pub fn routes() -> Router {
Router::new()
.route("/", get(RootRoute::root))
.fallback(RootRoute::not_found)
}
async fn root() -> Html<&'static str> {
Html("<p>Copyright Wyatt J. Miller 2024</p>")
}
pub async fn not_found() -> impl IntoResponse {
async fn not_found() -> impl IntoResponse {
(StatusCode::NOT_FOUND, "¯\\_(ツ)_/¯")
}
}