observe_middleware/3

Delegates the request processing.

Type:

foldl

Return:

updated z:context()

#middleware{} properties:

  • on: guard|rejected|request|welformed|handled

The guard phase runs before controller callbacks, with proxy and cookie metadata initialized. It can return a context with request_guard_response = {Status, Body} (an HTTP 400..599 status and binary body). Response headers set on that context are preserved. Before sending this response, core emits rejected synchronously. It does not run request, welformed, handled, or controller rendering. The returned context from rejected is ignored and observer exceptions cannot change the rejection response. Observers must return the context for other observers and initialize authentication themselves if needed; early requests are not authenticated. Keep rejection observers bounded and best-effort: they execute on the request process.

Guards can set request_guard_result to a server-owned map containing source (the producing module atom), guard_action, guard_reason, and crawl_behavior (binary classifications). Actions are allow, would_throttle, or throttle; crawl behavior is normal, excessive, or unknown. Reasons are producer-defined bounded values, not client input. Consumers must select supported sources and fields, never forward the entire map or include client identifiers. Guards may keep additional internal fields such as retry_after. This contract belongs to core, not a consumer. For normally handled requests, the result remains available in the handled phase. Optional telemetry consumers decide whether any enrichment or recording is needed.

Edit on GitHub

Observed by

Modules

mod_access_url

Share protected pages, images and feeds using signed URLs with the signing user's view permissions. Recipients do not need to log in as that user. Typical uses…

Modules

mod_analytics

Site Analytics measures site traffic, popular content, outgoing email activity and module-defined events without an external tracker. It helps operators…

Modules

mod_traffic_guard

Traffic Guard detects and limits excessive requests from individual IP addresses. It protects a site from rapid crawling and repeated page requests, including…