Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_query_flatten-0.1.0.tar.gz (2.8 kB view details)

Uploaded Source

Built Distribution

fastapi_query_flatten-0.1.0-py3-none-any.whl (3.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_query_flatten-0.1.0.tar.gz.

File metadata

  • Download URL: fastapi_query_flatten-0.1.0.tar.gz
  • Upload date:
  • Size: 2.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.7.1 CPython/3.11.4 Darwin/23.2.0

File hashes

Hashes for fastapi_query_flatten-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a4437b90b0149fec361af9411fea6620237e25e4b20ea29c6033de17168a8113
MD5 1a9619f6ababdd45e9af57b7577593bf
BLAKE2b-256 74f143dbd170f9dab5f6870b6a3e2d8fbab576c28dfb5808ecf315dd8be2a5ec

See more details on using hashes here.

File details

Details for the file fastapi_query_flatten-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_query_flatten-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8fa8ab58b107f0f820297916ed55ec23d552f442eb3cd5baa6c3eb9c75b23824
MD5 8029fbc65ad9ed06e4e5210b7c7b7fb9
BLAKE2b-256 714cfc361bbce6e21f0347d9feac2669d1e77ad6019a480e48c6ba5f2f9c6e1b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page