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.3.0.tar.gz
(18.8 kB
view hashes)
Built Distribution
Close
Hashes for fastapi_rfc7807-0.3.0-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d4339031c645ced3a1e256666d8015c95d2bc68780e4f93a056debac497d09c |
|
MD5 | f1e067760c4775d5606ccd7cb5ccb727 |
|
BLAKE2b-256 | 8df0fd63b29546d74e8e691379b3d584be63c8a1a4480d37d5518298dd75ef63 |