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.4.0.tar.gz
(19.5 kB
view details)
Built Distribution
File details
Details for the file fastapi_rfc7807-0.4.0.tar.gz
.
File metadata
- Download URL: fastapi_rfc7807-0.4.0.tar.gz
- Upload date:
- Size: 19.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 26a9bb42b5a339967d64ceddc449b88dc3c82943a3c3837ce4db673b72eab6c2 |
|
MD5 | 2866a1c28e87196f9c3b7839b5f86723 |
|
BLAKE2b-256 | 374e7476a6440cd06de7a6b4582551dc369aef1b53c74590337b4d74890c31d9 |
Provenance
File details
Details for the file fastapi_rfc7807-0.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: fastapi_rfc7807-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 734ccef53c55017b65986db6360bdb4d9620ccbce6702d1412ddaa1bdf3c538a |
|
MD5 | 92f1156fda58f43e0b0c859df2fb321a |
|
BLAKE2b-256 | 0552db2c90b711f772dcd762a4cdcc5b493f5cfc2113d73a2c45e13528ac74a9 |