Opinionated FastAPI Extended Route
A small utility for FastAPI/Starlette Route and Request to address the following:
Request.url_fordoesn't allow addingquery parametersat the moment.URLobjects can't have multiple keys like/?key=value&key=anothervalue.
With the following changes:
- Make
Request.url_forto match path parameters and use unmatched params for query parameters. - Provide a custom
Routewhich has a newRequesttype. - Allow
URLobject to add multiple keys inquery params. - ...
Example:
from fastapi import FastAPI
from fastapi.responses import PlainTextResponse
from fastapi_extended_route import Request, Route
def index(request: Request) -> PlainTextResponse:
url = request.url_for("index", key=value)
# url == "http://testserver/?key=value"
return PlainTextResponse(url)
app = FastAPI(
routes=[Route("/", index, name="index")],
)
As you can see the only change is to use Route from the package and
the new Request object will have a customized url_for method which
handles both path parameters and query parameters.
If/when these options are available in Starlette/FastAPI, this is no longer needed.
Metadata
Release files for fastapi-extended-route 0.1.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_extended_route-0.1.0.tar.gz | 4.2 kB | Without provenance | Details for fastapi_extended_route-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fastapi_extended_route-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for fastapi_extended_route-0.1.0-py3-none-any.whl |
Total release size: 8.5 kB
Release files / fastapi_extended_route-0.1.0.tar.gz
| Download URL | fastapi_extended_route-0.1.0.tar.gz |
|---|---|
| Size | 4.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e73998e14696f5433f1061834a5ac8c04c9e88a87198746d78206c1f1332380
|
|
BLAKE2b-256 checksum How to use checksums |
ae6cfa29cecf644827a4628f4d8aca907697f28d3d023f997fa1e7c2e81f1466
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Release files / fastapi_extended_route-0.1.0-py3-none-any.whl
| Download URL | fastapi_extended_route-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
02c8de0265aa045442ef204e11f77797bbddd63bf8b3e867696da971f279a818
|
|
BLAKE2b-256 checksum How to use checksums |
429002a9f4d2f5ba8e88d73898b943857740cf9d3c3646ab6d18318edc796d70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.1 CPython/3.9.13
|
Security for fastapi-extended-route 0.1.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.