Chain FastAPI dependencies without unused Depends!
Project description
fastapi-di-chain
Chain FastAPI dependencies without unused Depends!
Overview
fastapi-di-chain provides a utility to chain FastAPI dependencies in a way that avoids
unused Depends parameters, making your dependency injection cleaner,
more maintainable and easier to integrade.
Installation
pip install fastapi-di-chain
Usage
Suppose you have several dependencies that you want to chain together:
from fastapi import FastAPI, Depends
from fastapi_di_chain import DependsChain
app = FastAPI()
def my_rate_limiting_dependency() -> None:
# e.g. checks rate limiting
pass
def my_authentication_dependency() -> None:
# e.g. checks that user is authenticated to do a request
pass
dependency_chain = DependsChain | my_rate_limiting_dependency | my_authentication_dependency
@app.get("/profile", dependencies=[dependency_chain])
def profile() -> dict:
return {"user": 123}
License
fastapi-di-chain is distributed under the terms of the MIT license. Please see License.md for more information.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fastapi_di_chain-0.0.4.tar.gz.
File metadata
- Download URL: fastapi_di_chain-0.0.4.tar.gz
- Upload date:
- Size: 33.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3a592f0063903dfd4295ebe3770f9f8f53ebb5c3143cc94d3a3446d2f6fd28d
|
|
| MD5 |
3c54a7c5af4dae901ee7c3304d04a08b
|
|
| BLAKE2b-256 |
fbc68a464751c86d1fbad40ab33e9a48075d07e34387ee04bbf36c262cd894c9
|
File details
Details for the file fastapi_di_chain-0.0.4-py3-none-any.whl.
File metadata
- Download URL: fastapi_di_chain-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.7.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce095152502b305f596d4f39b4cc4e79bac4298ab90756871f6d12f92db4157e
|
|
| MD5 |
ac9ab68111586470fdbca65dbaa58430
|
|
| BLAKE2b-256 |
80c0254b1b91e24ff088a849fad471fe7494fcfcad8450f4ddef9521e14c0ec0
|