fastapi-di-0.0.1
توضیحات
Extracted the dependency injection process from fastapi.
| ویژگی | مقدار |
|---|---|
| سیستم عامل | - |
| نام فایل | fastapi-di-0.0.1 |
| نام | fastapi-di |
| نسخه کتابخانه | 0.0.1 |
| نگهدارنده | [] |
| ایمیل نگهدارنده | [] |
| نویسنده | sasano8 |
| ایمیل نویسنده | y-sasahara@ys-method.com |
| آدرس صفحه اصلی | https://github.com/sasano8/fastapi_di |
| آدرس اینترنتی | https://pypi.org/project/fastapi-di/ |
| مجوز | MIT |
# fastapi_di
Extracted the dependency injection process from fastapi.
Dependency injection by fastapi_di is only available in the async environment.
# Requirement
- Python 3.8+
# Installation
``` shell
poetry install fastapi_di
```
# Getting started
Dependency injection is done by decorating the function and calling do as follows.
``` Python
import asyncio
from fastapi import Depends
from fastapi_di import DI
di = DI()
def get_db():
yield {1: {"id": 1, "name": "bob", "memo": ""}}
@di.task()
async def update_user(db=Depends(get_db), *, user_id: int, memo: str):
record = db[user_id]
record["memo"] = memo
return record
async def main():
return await update_user.do(user_id=1, memo="test")
result = asyncio.run(main())
print(result)
# => {'id': 1, 'name': 'bob', 'memo': 'test'}}
```
# warning
This library is in the experimental stage.
نیازمندی
| مقدار | نام |
|---|---|
| >=0.63.0,<0.64.0 | fastapi |
| >=1.8.1,<2.0.0 | pydantic |
زبان مورد نیاز
| مقدار | نام |
|---|---|
| >=3.8,<4.0 | Python |
نحوه نصب
نصب پکیج whl fastapi-di-0.0.1:
pip install fastapi-di-0.0.1.whl
نصب پکیج tar.gz fastapi-di-0.0.1:
pip install fastapi-di-0.0.1.tar.gz