Requests¶
Request handling and per-request state management.
Request¶
The main request class that wraps the raw Gemini request and provides convenient accessors.
Request
¶
Wraps a Nauyaca GeminiRequest with convenient accessors.
Handlers receive this object as their first argument.
Example
@app.gemini("/user/{username}") def profile(request: Request, username: str): cert_id = request.client_cert_fingerprint viewer = cert_id[:16] if cert_id else 'anonymous' return f"# {username}'s Profile\n\nViewing as: {viewer}"
Attributes:
| Name | Type | Description |
|---|---|---|
app |
Xitzin
|
The Xitzin application instance. |
state |
RequestState
|
Arbitrary state storage for this request. |
path |
str
|
The URL path component. |
query |
str
|
The decoded query string (user input). |
raw_query |
str
|
The raw (URL-encoded) query string. |
client_cert |
Certificate | None
|
The client's TLS certificate, if provided. |
client_cert_fingerprint |
str | None
|
SHA-256 fingerprint of client certificate. |
Source code in src/xitzin/requests.py
client_cert_fingerprint
property
¶
SHA-256 fingerprint of the client certificate.
query
property
¶
The decoded query string.
Gemini uses URL query strings for user input (status 10/11 flow). This property decodes the query string for convenient access.
remote_addr
property
¶
The client's IP address, if available.
Note: This property returns the client IP address if it was set by the server or middleware. In CGI context, this is passed to scripts via the REMOTE_ADDR environment variable.
Returns:
| Type | Description |
|---|---|
str | None
|
The client IP address string, or None if not available. |
RequestState¶
Per-request state storage for passing data between middleware and handlers.
RequestState
¶
Arbitrary state storage for a request.
Middleware and handlers can store arbitrary data here.
Example
request.state.user = get_current_user() request.state.start_time = time.time()