added health, fallback not found endpoints

This commit is contained in:
Wyatt J. Miller 2025-03-15 18:02:13 -04:00
parent cae531eae3
commit 3cd6b6e8b3
2 changed files with 10 additions and 4 deletions

View File

@ -115,7 +115,8 @@ async fn main() {
TraceLayer::new_for_http()
.make_span_with(trace::DefaultMakeSpan::new().level(tracing::Level::INFO))
.on_response(trace::DefaultOnResponse::new().level(tracing::Level::INFO)),
);
)
.fallback(routes::root::RootRoute::not_found);
// .layer(cors);
//.layer(GovernorLayer {
// config: governor_conf,

View File

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