File tree Expand file tree Collapse file tree 2 files changed +12
-2
lines changed
Expand file tree Collapse file tree 2 files changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use aide::{
77} ;
88use axum:: {
99 extract:: { MatchedPath , Request } ,
10- http:: Method ,
10+ http:: { self , Method } ,
1111 Extension , Router ,
1212} ;
1313use axum_prometheus:: PrometheusMetricLayer ;
@@ -31,6 +31,7 @@ pub mod routes;
3131pub const DOCS_ROUTE : & str = "/v0/docs" ;
3232pub const WONDERS_ROUTE : & str = "/v0/wonders" ;
3333pub const METRICS_ROUTE : & str = "/metrics" ;
34+ pub const HEALTH_ROUTE : & str = "/health" ;
3435
3536pub fn get_app ( ) -> Router {
3637 // API docs generation
@@ -62,6 +63,10 @@ pub fn get_app() -> Router {
6263 . nest_api_service ( WONDERS_ROUTE , wonders:: routes ( ) )
6364 . nest_api_service ( DOCS_ROUTE , docs:: routes ( ) )
6465 . api_route ( METRICS_ROUTE , get ( || async move { metric_handle. render ( ) } ) )
66+ . api_route (
67+ HEALTH_ROUTE ,
68+ get ( || async { ( http:: StatusCode :: OK , "Healthy!" ) } ) ,
69+ )
6570 . fallback ( handler_404)
6671 . finish_api_with ( & mut api, api_docs)
6772 // Docs generation
Original file line number Diff line number Diff line change 11use pretty_assertions:: assert_eq;
2- use world_wonders_api:: METRICS_ROUTE ;
2+ use world_wonders_api:: { HEALTH_ROUTE , METRICS_ROUTE } ;
33
44mod common;
55use common:: get_server;
@@ -8,6 +8,11 @@ use common::get_server;
88async fn test_routes_misc ( ) {
99 let server = get_server ( ) ;
1010
11+ // HEALTH
12+ let response = server. get ( HEALTH_ROUTE ) . await ;
13+ response. assert_status_ok ( ) ;
14+ response. assert_text_contains ( "Healthy!" ) ;
15+
1116 // 404
1217 let response = server. get ( "not-a-route" ) . await ;
1318 response. assert_status_not_found ( ) ;
You can’t perform that action at this time.
0 commit comments