add redirects & nest api inside root router

This commit is contained in:
2025-09-03 01:34:36 +02:00
parent 5050557252
commit 437a7fcdf9
2 changed files with 31 additions and 1 deletions

View File

@@ -1,9 +1,18 @@
use axum::{Router, http::StatusCode, routing::get};
use chrono::{NaiveDate, Utc};
use crate::router::redirects::redirects;
mod redirects;
pub fn init() -> Router {
Router::new().merge(redirects()).nest("/api/", api())
}
fn api() -> Router {
Router::new()
.route("/", get(async || "root"))
.route("/", get(async || StatusCode::OK))
.route("/live", get(async || StatusCode::OK))
.route("/discord/member-count", get(get_member_count))
.route("/days/community", get(get_days_since_community_formation))
}

21
src/router/redirects.rs Normal file
View File

@@ -0,0 +1,21 @@
use axum::{Router, response::Redirect, routing::get};
pub fn redirects() -> Router {
Router::new()
.route(
"/discord",
get(Redirect::temporary("https://discord.gg/NBXq95C")),
)
.route(
"/github",
get(Redirect::temporary("https://github.com/gractwo")),
)
.route(
"/youtube",
get(Redirect::temporary("https://www.youtube.com/@gractwopl")),
)
.route(
"/bsky",
get(Redirect::temporary("https://bsky.app/profile/gractwo.pl")),
)
}