🪄 FastAPI Magic Router ✨
Have you come here seeking a magical way to define FastAPI routes?
app = FastAPI()
route = magic_router(app)
route("GET /api/users ", user.list_)
route("GET /api/users/{user_id}", user.get)
route("POST /api/users ", user.create)
route("PATCH /api/users/{user_id}", user.update)
route("DELETE /api/users/{user_id}", user.delete_)
Come, I shall grant you your wish!
Default Router vs Magic Router
from fastapi import FastAPI
from pydantic import BaseModel
from magic_router import magic_router, magic
class Response(BaseModel):
path: str
# Default Router -----------------------------------------------------------------------
app = FastAPI()
not_so_magical_path = "/api/not-so-magical"
async def not_so_magical_endpoint():
return Response(path=not_so_magical_path)
app.get(
not_so_magical_path,
response_model=Response,
tags=["main"],
operation_id="not_so_magical_endpoint",
name="not_so_magical_endpoint",
)(not_so_magical_endpoint)
# Magic Router -------------------------------------------------------------------------
route = magic_router(app)
async def magical_endpoint() -> Response:
return Response(path=magic(magical_endpoint).path)
route("GET /api/magical", magical_endpoint)
# --------------------------------------------------------------------------------------
Metadata
Release files for fastapi-magic-router 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fastapi_magic_router-0.2.0.tar.gz | 4.6 kB | Without provenance | Details for fastapi_magic_router-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_magic_router-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for fastapi_magic_router-0.2.0-py3-none-any.whl |
Total release size: 9.0 kB
Release files / fastapi_magic_router-0.2.0.tar.gz
| Download URL | fastapi_magic_router-0.2.0.tar.gz |
|---|---|
| Size | 4.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a7e0a56c4a485be30a3572e7105b33e2ca0d534643929ffaca339a2032ef85ae
|
|
BLAKE2b-256 checksum How to use checksums |
e8f7765ac263100abe07cdb8088b3edb7d476bc70ed9b0bcb84c5b76e88361bb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Release files / fastapi_magic_router-0.2.0-py3-none-any.whl
| Download URL | fastapi_magic_router-0.2.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d84d1fa31f186d01473a034192bf31e3b2d13656602122091e84d593e55e44a3
|
|
BLAKE2b-256 checksum How to use checksums |
5505909ebe1cbde88d694c26a0e1dc6df547c0e80300002be90ffd1a25c268e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.13
|
Security for fastapi-magic-router 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.