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
Release history Release notifications | RSS feed
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.2.3.tar.gz
(18.7 kB
view details)
Built Distribution
File details
Details for the file fastapi_rfc7807-0.2.3.tar.gz
.
File metadata
- Download URL: fastapi_rfc7807-0.2.3.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/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5e47e9557a8a423d462cba8c5e972bf0ac32225d9a94fde1d530289a26ab8bf3 |
|
MD5 | ea96f81e141a32e9c8235ea55a916ca5 |
|
BLAKE2b-256 | bc0dfefe75f4d9ea356fa92891dffa6759cee3d7ed023ad05fc0a269ffed114c |
Provenance
File details
Details for the file fastapi_rfc7807-0.2.3-py2.py3-none-any.whl
.
File metadata
- Download URL: fastapi_rfc7807-0.2.3-py2.py3-none-any.whl
- Upload date:
- Size: 19.1 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/50.3.1 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8efbaa6e083d0ce0a535f00f7284a499c89aef5c9704cb8a93fcac1d6f024dee |
|
MD5 | 627436670c5dd265380e9edb420a5e52 |
|
BLAKE2b-256 | 7d9b8b17b7a3f91f07150f2c4bd887ceefb4b741fba986321ec441afd2bd4b9a |