Skip to content

Internals Responses

Stefan Crkvenjakov edited this page Oct 7, 2026 · 1 revision

Responses internals

Framework Internals · Developer guide

Response holds status code/message, header map, payload and optional forced MIME. SenderRegistry and MimeResolver are lazy static collaborators; setRegistry replaces the sender mapping. MIME resolution uses an explicit override, known file extension, supported Accept selection, then JSON fallback. A JSON array is wrapped in status/message/data before passing to a sender.

Sender implementations advertise supportedMimes and emit status/headers plus payload conversion or file streams. HTML/text/CSS/JS/media/PDF/binary handling differs from JSON/XML conversion; use the focused sender pages for exact fallbacks, checks and side effects. Binary serves file payloads when explicitly selected or mapped; unsupported MIME raises RuntimeException. File sends are not storage authorization checks by themselves.

Redirect stores a target string and inherits breadcrumb/session initialization. The web bootstrap handles it with Location and exit. Response::redirect is instead immediate and returns void. Breadcrumbs records the last rendered URI; the bootstrap updates it only after view emission. Response/Redirect branches exit earlier. HEAD uses a body-discarding output buffer around normal emission.

The bootstrap's local Exception catch can terminate with a raw Internal error message, while other uncaught errors reach the global handler. Application code should return appropriate responses for known errors rather than depend on that inconsistency.

Component reference

Clone this wiki locally