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.1.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

fastapi_rfc7807-0.1.0-py2.py3-none-any.whl (18.9 kB view details)

Uploaded Python 2 Python 3

File details

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

File metadata

  • Download URL: fastapi_rfc7807-0.1.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for fastapi_rfc7807-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4ff1d9ca776eb2f9e37cd69a567bda68726cc6e4df45e6da9882d88f7d0409af
MD5 7249eff99b224a1eebe11613e71b213a
BLAKE2b-256 cb0a8f622cc3122419f18073c253c0b37bf4c515f60a169a1e42080aaca3a97c

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: fastapi_rfc7807-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 18.9 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.48.2 CPython/3.8.5

File hashes

Hashes for fastapi_rfc7807-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 08fc6fdd31a10b7f5c7fa7ff5e7a8f06f4febe5560f06fa41140d5d03116a2cd
MD5 47f795c64a277ca3967429a51e4edb75
BLAKE2b-256 0f144392112017203acb0d8c18bd4372befc77ffab7cd14c03defdd51a60abd0

See more details on using hashes here.

Provenance

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