No project description provided
Project description
QueryFlattenMiddleware for FastAPI
QueryFlattenMiddleware
is a custom middleware for FastAPI applications that flattens query parameters separated by a specified delimiter. This is particularly useful for endpoints that need to handle multiple values for the same query parameter without using the standard array format.
Features
- Customizable Delimiter: Easily configure the delimiter used for splitting query parameter values.
- Seamless Integration: Works as middleware within any FastAPI application.
- Efficient Query Handling: Simplifies the process of handling multiple query parameters by flattening them, making endpoint logic cleaner and more straightforward.
Requirements
- Python 3.8.1+
- FastAPI
Installation
To install QueryFlattenMiddleware
, you can use pip:
pip install fastapi-query-flatten
Usage
To use QueryFlattenMiddleware
in your FastAPI application, simply add it as middleware in your app instance. Specify the delimiter you want to use for splitting query parameter values. The default delimiter is a comma (,
).
Example
from fastapi import FastAPI
from fastapi_query_flatten import QueryFlattenMiddleware
app = FastAPI()
# Add QueryFlattenMiddleware with a custom delimiter
app.add_middleware(QueryFlattenMiddleware, delimiter=",")
With the middleware in place, a request to /items/?filter=value1,value2,value3
will be processed as if it were /items/?filter=value1&filter=value2&filter=value3
, allowing the filter
query parameter to be easily handled as multiple values.
Contributing
Contributions are welcome! If you have a feature request, bug report, or a pull request, please open an issue or submit a PR on the project's repository.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file fastapi_query_flatten-0.1.2.tar.gz
.
File metadata
- Download URL: fastapi_query_flatten-0.1.2.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.8.18 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a0d1422347868c5ef4d42359c6f31ef47afa1227713b3f2178c7b980c429597a |
|
MD5 | d5b6a5f6c311203555b0a661b4b276e8 |
|
BLAKE2b-256 | 3bfe313373343748cf87d6638ae590e501e4e7253a7ac296189c1c14f31fd0f4 |
File details
Details for the file fastapi_query_flatten-0.1.2-py3-none-any.whl
.
File metadata
- Download URL: fastapi_query_flatten-0.1.2-py3-none-any.whl
- Upload date:
- Size: 3.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.8.18 Linux/6.2.0-1019-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4869eeb13e9b0a7b687a7a0fc62f93f08975023f92683309cbba16344ecc35c8 |
|
MD5 | 3b573553233b92e22a42c877e12b945f |
|
BLAKE2b-256 | 909c2f13b063acfed5bd7c1d1b339edaccbb54b18eb91a608c99b70a87407f6b |