added health, fallback not found endpoints
This commit is contained in:
parent
cae531eae3
commit
3cd6b6e8b3
@ -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,
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user