feat: add health check and remove old code

This commit is contained in:
Sandro Eiler 2023-10-21 22:47:23 +02:00
parent c558a6623c
commit f869b0f067

View file

@ -39,7 +39,7 @@ async fn main() -> Result<()> {
.route_layer(middleware::from_fn(web::mw_auth::mw_require_auth)); .route_layer(middleware::from_fn(web::mw_auth::mw_require_auth));
let routes_all = Router::new() let routes_all = Router::new()
.merge(routes_hello()) .merge(Router::new().route("/health_check", get(|| async {})))
.merge(web::routes_login::routes()) .merge(web::routes_login::routes())
.nest("/api", routes_apis) .nest("/api", routes_apis)
.layer(middleware::map_response(main_response_mapper)) .layer(middleware::map_response(main_response_mapper))
@ -102,25 +102,7 @@ async fn main_response_mapper(
} }
/// Serve static files /// Serve static files
// FIXME: remove
fn routes_static() -> Router { fn routes_static() -> Router {
Router::new().nest_service("/", get_service(ServeDir::new("./"))) Router::new().nest_service("/", get_service(ServeDir::new("./")))
} }
fn routes_hello() -> Router {
Router::new()
.route("/hello", get(handler_hello))
.route("/hello2/:name", get(handler_hello2))
}
// e.g. `hello?name=jen`
async fn handler_hello(Query(params): Query<HelloParams>) -> impl IntoResponse {
println!("->> {:<12} - handler_hello - {params:?}", "HANDLER");
let name = params.name.as_deref().unwrap_or("World!");
Html(format!("Hello <strong>{name}</strong>!"))
}
// e.g. `hello/jen`
async fn handler_hello2(Path(name): Path<String>) -> impl IntoResponse {
println!("->> {:<12} - handler_hello_path - {name:?}", "HANDLER");
Html(format!("Hello <strong>{name}</strong>!"))
}