File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -371,11 +371,13 @@ def register_core(self) -> None:
371
371
def add_health_check (self ) -> None :
372
372
"""Add a health check."""
373
373
374
+ mgmt_router = APIRouter (prefix = self .app .state .router_prefix )
375
+
374
376
async def ping ():
375
377
"""Liveliness probe."""
376
378
return {"message" : "PONG" }
377
379
378
- self . app . router .add_api_route (
380
+ mgmt_router .add_api_route (
379
381
name = "Ping" ,
380
382
path = "/_mgmt/ping" ,
381
383
response_model = Dict ,
@@ -389,10 +391,9 @@ async def ping():
389
391
response_class = self .response_class ,
390
392
methods = ["GET" ],
391
393
endpoint = ping ,
392
- tags = ["Liveliness/Readiness" ],
393
394
)
394
395
395
- self . app . router .add_api_route (
396
+ mgmt_router .add_api_route (
396
397
name = "Health" ,
397
398
path = "/_mgmt/health" ,
398
399
response_model = Dict ,
@@ -406,8 +407,8 @@ async def ping():
406
407
response_class = self .response_class ,
407
408
methods = ["GET" ],
408
409
endpoint = self .health_check ,
409
- tags = ["Liveliness/Readiness" ],
410
410
)
411
+ self .app .include_router (mgmt_router , tags = ["Liveliness/Readiness" ])
411
412
412
413
def add_route_dependencies (
413
414
self , scopes : List [Scope ], dependencies : List [Depends ]
Original file line number Diff line number Diff line change @@ -34,6 +34,9 @@ def test_api_prefix(TestCoreClient, prefix):
34
34
)
35
35
36
36
with TestClient (api .app , base_url = "http://stac.io" ) as client :
37
+ ping = client .get (f"{ prefix } /_mgmt/ping" )
38
+ assert ping .status_code == 200 , ping .json () == {"message" : "PONG" }
39
+
37
40
landing = client .get (f"{ prefix } /" )
38
41
assert landing .status_code == 200 , landing .json ()
39
42
You can’t perform that action at this time.
0 commit comments