An extension for AWS Lambda Powertools that provides model binding for request bodies, query parameters and path parameters.
Project description
powertools-request-binding
Middleware for AWS Lambda Powertools Event Handler that validates and injects route arguments using Modmex models instead of Pydantic.
Why
Powertools request validation currently requires Pydantic. This package provides a lightweight alternative for request binding in REST API and HTTP API handlers when your project uses Modmex.
Installation
poetry add powertools-request-binding modmex
Usage
from typing import Annotated
from modmex import BaseModel
from aws_lambda_powertools.event_handler import APIGatewayRestResolver
from powertools_request_binding import Body, Query, RequestBindingMiddleware
class CreateTodoRequest(BaseModel):
title: str
completed: bool
app = APIGatewayRestResolver()
app.use(middlewares=[RequestBindingMiddleware()])
@app.post("/todos/<todo_id>")
def create_todo(
todo_id: int,
payload: Annotated[CreateTodoRequest, Body()],
source: Annotated[str | None, Query()] = None,
):
return {
"todo_id": todo_id,
"title": payload.title,
"completed": payload.completed,
"source": source,
}
Supported Input Sources
- Path parameters
- Query parameters
- Headers
- JSON body
Notes
- This package focuses on request argument binding only.
- Powertools
Depends(...)support remains native and should be used directly from Powertools when needed.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file powertools_request_binding-0.1.0.tar.gz.
File metadata
- Download URL: powertools_request_binding-0.1.0.tar.gz
- Upload date:
- Size: 6.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/25.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e0a8e36daf49b34eef3f693bb16118f4848f494ac190a4770d3c6aa5f53b527
|
|
| MD5 |
15f14934db29d10e5219402743e6553f
|
|
| BLAKE2b-256 |
b227a53e6135ff02555b15dcc4cf5a91b7dd76bd188e22e50b7079b604ab65e1
|
File details
Details for the file powertools_request_binding-0.1.0-py3-none-any.whl.
File metadata
- Download URL: powertools_request_binding-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.3 CPython/3.13.3 Darwin/25.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8eff3ffd839476a6144647d1dbd474a8b7e1f2ffde049789a14fe743fded620f
|
|
| MD5 |
ae0bee2e36f8ef29e997e8ba3c32ea9e
|
|
| BLAKE2b-256 |
8cfb57cac9be620dc6f60c7cec7fb8e59a31d561b18e22e2568a0df24a9d6248
|