Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/vapor-ware/fastapi-rfc7807
RFC-7807 compliant problem detail error response handler for FastAPI applications
https://github.com/vapor-ware/fastapi-rfc7807
error-handling errors fastapi middleware rfc-7807 rfc7807
Last synced: about 2 months ago
JSON representation
RFC-7807 compliant problem detail error response handler for FastAPI applications
- Host: GitHub
- URL: https://github.com/vapor-ware/fastapi-rfc7807
- Owner: vapor-ware
- License: gpl-3.0
- Created: 2020-08-07T19:46:13.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-08-04T11:10:17.000Z (over 1 year ago)
- Last Synced: 2024-11-09T15:47:19.662Z (3 months ago)
- Topics: error-handling, errors, fastapi, middleware, rfc-7807, rfc7807
- Language: Python
- Homepage:
- Size: 69.3 KB
- Stars: 19
- Watchers: 6
- Forks: 7
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Codeowners: .github/CODEOWNERS
Awesome Lists containing this project
README
# fastapi-rfc7807
[FastAPI](https://fastapi.tiangolo.com/) middleware which translates server-side exceptions
into [RFC-7807](https://tools.ietf.org/html/rfc7807) 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`.```python
from fastapi import FastAPI
from fastapi_rfc7807 import middlewareapp = FastAPI()
middleware.register(app)@app.get('/error')
async def error():
raise ValueError('something went wrong')```
The resulting error returned from the server looks like:
```console
$ curl localhost:8000/error
{"exc_type":"ValueError","type":"about:blank","title":"Unexpected Server Error","status":500,"detail":"something went wrong"}
```See the [examples](examples) directory for additional examples.