Skip to main content

FastAPI middleware for RFC-7807 compliant error responses

Project description

fastapi-rfc7807

FastAPI middleware which translates server-side exceptions into RFC-7807 compliant problem detail error responses.

Installation

fastapi_rfc7807 requires Python 3.6+

pip install fastapi_rfc7807

Usage

Below is a simple example which shows the bare minimum needed to configure a FastAPI application with fastapi_rfc7807.

from fastapi import FastAPI 
from fastapi_rfc7807 import middleware

app = FastAPI()
middleware.register(app)


@app.get('/error')
async def error():
    raise ValueError('something went wrong')

The resulting error returned from the server looks like:

$ curl localhost:8000/error
{"exc_type":"ValueError","type":"about:blank","title":"Unexpected Server Error","status":500,"detail":"something went wrong"}

See the examples directory for additional examples.

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

fastapi_rfc7807-0.5.0.tar.gz (19.5 kB view details)

Uploaded Source

Built Distribution

fastapi_rfc7807-0.5.0-py2.py3-none-any.whl (20.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file fastapi_rfc7807-0.5.0.tar.gz.

File metadata

  • Download URL: fastapi_rfc7807-0.5.0.tar.gz
  • Upload date:
  • Size: 19.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.8

File hashes

Hashes for fastapi_rfc7807-0.5.0.tar.gz
Algorithm Hash digest
SHA256 7a93b6cda8e2188970d6b4a26dc0a17a514543251027505d962d16e3292fb700
MD5 628b801b23f1afa240c1928b9e676685
BLAKE2b-256 59fe32f5420a370bb8e6f09cf89e20d0153ddd7bbdb831c6257c3cd61d985f7a

See more details on using hashes here.

File details

Details for the file fastapi_rfc7807-0.5.0-py2.py3-none-any.whl.

File metadata

  • Download URL: fastapi_rfc7807-0.5.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.5.0 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.61.1 CPython/3.8.8

File hashes

Hashes for fastapi_rfc7807-0.5.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 2d34202f8da5ef87b1862e3efb41c7cc3e1648b5b2a2e4fedfac25ae31b6be27
MD5 1372fbcc291e9fe01835ba214a66a228
BLAKE2b-256 b62ea0b121f39ea646d7d7ce7eea928c96e23f1acdd19e60a7fbf6387f5a576c

See more details on using hashes here.

Supported by

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