Skip to main content

Add your description here

Project description

starlette-rfc7807

A simple middleware and exception class to enable any Starlette (including FastAPI) project to always return an https://datatracker.ietf.org/doc/html/rfc7807 formatted response.

Example Use

import uvicorn
from fastapi import FastAPI, HTTPException
from starlette_rfc7807.middleware import http_exception_handler, ProblemMiddleware
from loguru import logger

from myservice.routers import health



def get_application() -> FastAPI:
    logger.info("Creating FastAPI application")

    application = FastAPI()
    # overwrite the default http exception handler
    application.add_exception_handler(HTTPException, http_exception_handler)  
    # your other middleware
    application.add_middleware(SentryMiddleware)
    # must be last
    application.add_middleware(ProblemMiddleware)

    application.include_router(health.router) # example route

    return application


app = get_application()

if __name__ == "__main__":
    uvicorn.run("app:app", host="0.0.0.0", port=8080, reload=True)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

starlette_rfc7807-0.1.2.tar.gz (20.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

starlette_rfc7807-0.1.2-py3-none-any.whl (15.5 kB view details)

Uploaded Python 3

File details

Details for the file starlette_rfc7807-0.1.2.tar.gz.

File metadata

  • Download URL: starlette_rfc7807-0.1.2.tar.gz
  • Upload date:
  • Size: 20.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.7.14

File hashes

Hashes for starlette_rfc7807-0.1.2.tar.gz
Algorithm Hash digest
SHA256 93be7666c5f13f89d2302634096f5c9fee7cdc237877fba24db904ffaaf5e9a3
MD5 917cdc1f4f08efcfc7a2cb2670db27aa
BLAKE2b-256 aafa3c17ebd2124cd3cce0326a604ad6d4bb1ca0ac38c7fbdf608490d8fd77b8

See more details on using hashes here.

File details

Details for the file starlette_rfc7807-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for starlette_rfc7807-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d5c897551c64017599957219d996667b54f3e51faf5fb6562e62910d6fc97d35
MD5 7ed102a6ee4a52904ade61c9c2ce1ab1
BLAKE2b-256 0ed035889e0021a466c90caf49985fa18daedcfecd22c407f9b507505ef1d399

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page