Skip to content

Latest commit

 

History

History
29 lines (22 loc) · 731 Bytes

README.md

File metadata and controls

29 lines (22 loc) · 731 Bytes

fastapi_healthcheck_uri

A module to have a FastAPI HealthCheck reach out to a URI to validate external service health.

Adding Health Checks

Here is what you need to get started.

from fastapi import FastAPI
from fastapi_healthcheck import HealthCheckFactory, healthCheckRoute
from fastapi_healthcheck_uri import HealthCheckUri

app = FastAPI()

# Add Health Checks
_healthChecks = HealthCheckFactory()
_healthChecks.add(
    HealthCheckUri(
        alias='reddit', 
        connectionUri="https://www.reddit.com/r/aww.json", 
        tags=('external', 'reddit', 'aww'),
        healthyCode=200,
        unhealthyCode=500
    )
)
app.add_api_route('/health', endpoint=healthCheckRoute(factory=_healthChecks))