@@ -321,7 +321,13 @@ async fn handle_request_inner<T: DeserializeOwned + GraphQLRequestLike>(
321
321
322
322
graphql_request :: < T > ( req, & Arc :: new ( app_ctx) , req_counter) . await
323
323
}
324
-
324
+ hyper:: Method :: GET if req. uri ( ) . path ( ) == "/status" => {
325
+ let status_response = Response :: builder ( )
326
+ . status ( StatusCode :: OK )
327
+ . header ( CONTENT_TYPE , "application/json" )
328
+ . body ( Body :: from ( r#"{"message": "ready"}"# ) ) ?;
329
+ Ok ( status_response)
330
+ }
325
331
hyper:: Method :: GET => {
326
332
if let Some ( TelemetryExporter :: Prometheus ( prometheus) ) =
327
333
app_ctx. blueprint . telemetry . export . as_ref ( )
@@ -330,7 +336,6 @@ async fn handle_request_inner<T: DeserializeOwned + GraphQLRequestLike>(
330
336
return prometheus_metrics ( prometheus) ;
331
337
}
332
338
} ;
333
-
334
339
not_found ( )
335
340
}
336
341
_ => not_found ( ) ,
@@ -377,6 +382,39 @@ pub async fn handle_request<T: DeserializeOwned + GraphQLRequestLike>(
377
382
378
383
#[ cfg( test) ]
379
384
mod test {
385
+ use super :: * ;
386
+ use crate :: core:: async_graphql_hyper:: GraphQLRequest ;
387
+ use crate :: core:: blueprint:: Blueprint ;
388
+ use crate :: core:: config:: { Config , ConfigModule } ;
389
+ use crate :: core:: rest:: EndpointSet ;
390
+ use crate :: core:: runtime:: test:: init;
391
+ use crate :: core:: valid:: Validator ;
392
+
393
+ #[ tokio:: test]
394
+ async fn test_health_endpoint ( ) -> anyhow:: Result < ( ) > {
395
+ let sdl = tokio:: fs:: read_to_string ( tailcall_fixtures:: configs:: JSONPLACEHOLDER ) . await ?;
396
+ let config = Config :: from_sdl ( & sdl) . to_result ( ) ?;
397
+ let blueprint = Blueprint :: try_from ( & ConfigModule :: from ( config) ) ?;
398
+ let app_ctx = Arc :: new ( AppContext :: new (
399
+ blueprint,
400
+ init ( None ) ,
401
+ EndpointSet :: default ( ) ,
402
+ ) ) ;
403
+
404
+ let req = Request :: builder ( )
405
+ . method ( Method :: GET )
406
+ . uri ( "http://localhost:8000/status" . to_string ( ) )
407
+ . body ( Body :: empty ( ) ) ?;
408
+
409
+ let resp = handle_request :: < GraphQLRequest > ( req, app_ctx) . await ?;
410
+
411
+ assert_eq ! ( resp. status( ) , StatusCode :: OK ) ;
412
+ let body = hyper:: body:: to_bytes ( resp. into_body ( ) ) . await ?;
413
+ assert_eq ! ( body, r#"{"message": "ready"}"# ) ;
414
+
415
+ Ok ( ( ) )
416
+ }
417
+
380
418
#[ test]
381
419
fn test_create_allowed_headers ( ) {
382
420
use std:: collections:: BTreeSet ;
0 commit comments