Requests
Almasix’s Request is the application façade over the ASGI request. Application code should type-hint almasix.http.Request, not Starlette/FastAPI request types.
Accessing the request
Section titled “Accessing the request”Inject Request into a controller action (or use a FormRequest, which proxies to the same bag):
from almasix.http import Controller, Request
class DemoController(Controller): async def echo_bag(self, request: Request) -> dict: return { "all": request.all(), "only": request.only("q", "page"), "path": request.path, "method": request.method, }Input bags
Section titled “Input bags”| Method | Meaning |
|---|---|
all() / input() |
Query string merged with body (body wins) |
query() |
Query string only |
post() |
Body only (JSON object or form fields) |
json() |
Parsed JSON payload |
route() |
Path / route parameters (not in all()) |
only(...) / except_(...) |
Subset of the merged input |
has / has_any / filled / missing |
Presence helpers |
boolean / integer / float / string |
Coercion helpers |
request.input("email")request.query("page", 1)request.route("post")request.merge({"source": "demo"})Headers, cookies, and client metadata
Section titled “Headers, cookies, and client metadata”request.header("Accept")request.cookie("theme")request.bearer_token()request.ip()request.user_agent()request.is_json()request.is_method("POST")if request.has_file("avatar"): upload = request.file("avatar") data = await upload.read()UploadedFile exposes filename, content_type, size, and async read / seek. Storage disks arrive in a later milestone; until then handle bytes in the action or write to disk yourself.
Related
Section titled “Related”- Validation — FormRequest on top of this bag
- Controllers
- Responses