add redirects & nest api inside root router
This commit is contained in:
@@ -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
21
src/router/redirects.rs
Normal 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")),
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user