Layout chain and route contract debug middleware.
When config.debug is True, adds X-Chirp-Layout-* and X-Chirp-Route-* headers to help diagnose layout resolution and route contract metadata.
Also emitsX-Chirp-Render-Planwith a base64-encoded compact JSON snapshot
of the render plan for consumption by the HTMX debug tray.
middleware.layout_debug
| Name | Type | Default | Description |
|---|---|---|---|
type
|
|
— | |
qualified_name
|
|
— | |
element_type
|
|
— | |
description
|
|
— | |
source_file
|
|
— | |
line_number
|
|
— | |
is_autodoc
|
|
— | |
autodoc_element
|
|
— | |
_autodoc_template
|
|
— | |
_autodoc_url_path
|
|
— | |
_autodoc_page_type
|
|
— | |
title
|
|
— | |
doc_content_hash
|
|
— |
Symbols on this page
Store layout chain metadata on the request for the layout debug middleware.
Build a rich render plan payload from the stashed RenderPlan.
Uses the publicget_render_plan()API to access the frozen RenderPlan object, producing a richer…
Trim a render plan snapshot to header-safe size (~2 KB).
Fallback used when the frozen RenderPlan is not available.
Middleware that adds X-Chirp-Layout-* and X-Chirp-Route-* headers when config.debug.
set_layout_debug_metadata
function
def set_layout_debug_metadata(request: Request | None, chain: str, match: str, mode: str) -> None
Store layout chain metadata on the request for the layout debug middleware.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
request
|
Request | None
|
— | |
chain
|
str
|
— | |
match
|
str
|
— | |
mode
|
str
|
— |
_build_render_plan_payload
function
def _build_render_plan_payload(request: Request) -> dict | None
Build a rich render plan payload from the stashed RenderPlan.
Uses the publicget_render_plan()API to access the frozen
RenderPlan object, producing a richer payload than the old compact
snapshot (which was capped at 20 context keys and ~2 KB).
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
request
|
Request
|
— |
_compact_render_plan
function
def _compact_render_plan(plan: dict) -> dict
Trim a render plan snapshot to header-safe size (~2 KB).
Fallback used when the frozen RenderPlan is not available.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
plan
|
dict
|
— |
LayoutDebugMiddleware
class
Middleware that adds X-Chirp-Layout-* and X-Chirp-Route-* headers when config.debug.
View source · /home/runner/work/chirp/chirp/site/../src/chirp/middleware/layout_debug.py:1