Skip to content

Latest commit

 

History

History
51 lines (39 loc) · 1.68 KB

README.md

File metadata and controls

51 lines (39 loc) · 1.68 KB

FastAPI Health 🚑️

Latest Commit
Package version

The goal of this package is to help you to implement the Health Check API pattern.

Installation

pip install fastapi-health

Usage

Using this package, you can create the health check endpoint dynamically using different conditions. Each condition is a callable and you can even have dependencies inside of it.

from fastapi import FastAPI, Depends
from fastapi_health import health

def get_session():
    return True

def is_database_online(session: bool = Depends(get_session)):
    return session

app = FastAPI()
app.add_api_route("/health", health([is_database_online]))

The /health endpoint on the example can return two possible response status code:

  • 200 (Ok): conditions are satisfied.
  • 503 (Service Unavailable): at least one condition is false.

License

This project is licensed under the terms of the MIT license.