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.1.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_query_flatten-0.1.1.tar.gz
  • Upload date:
  • Size: 2.7 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

Hashes for fastapi_query_flatten-0.1.1.tar.gz
Algorithm Hash digest
SHA256 7165ce5b3989aad82857ab972227d1f44d26ce9ace2951b30ab6fab0f46f0db2
MD5 fb4dc82952a94b001b346474d2efa00e
BLAKE2b-256 14ee9b7e04987f4b2eb1b3a38c95d8b743003f822d29dc2eb8bf11cb23be3969

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_query_flatten-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f590f47a0d4adfad9732d6c41c40e17d33f248736f9d8199e59ec2aafe0dbd99
MD5 48404c5471824a3923098e69c8ccae6d
BLAKE2b-256 3abaa9dbec4eccacf24a913a686c8f743e9d6ecaaee5d0fd4a14e431617026ec

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