Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nitedani/fastapi-cls-controller


https://github.com/nitedani/fastapi-cls-controller

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

        

A class/decorator based router for FastAPI
---

```python
# fruit_controller.py
from fastapi_cls_controller import controller, delete, get, post, put, ...

@controller(
# Arguments are forwarded to the fastapi APIRouter.
prefix="/fruits",
)
class FruitController:
@post("")
async def create(self, body: CreateFruit):
...

@get("/{fruit_id}")
async def get(self, fruit_id: str):
...

```

```python
# main.py
app.include_router(FruitController())
```