Expand description
Public API types and utilities for the Actus controller system — the
Controller trait, the typed Params / ExtractedParams, the route
metadata (Verb, ParamDef, RouteDef), and the route-resolution
routing helpers. This is what user code and the #[controller] /
routes! / app_routes! macros’ generated code interact with.
Modules§
- reply
- Contains the user-facing API for creating replies.
- routing
- Route resolution helpers — matching a request path + verb against a
controller’s
&[RouteDef]and extracting the path/query/body parameters. Used by the#[controller]macro’s generated dispatch; exposed for tools and tests that need to resolve routes directly.
Macros§
- app_
routes - Declares the application’s URL blueprint and generates its
init(). - reply
- Creates a
Reply(aResult<ReplyData, WebError>) for a success case. - routes
- A marker macro to define routes within a
#[controller]impl block. The#[controller]procedural macro is responsible for parsing this.
Structs§
- Extracted
Params - Parameters extracted after route resolution — path captures plus the
declared query and body values. The
#[controller]macro reads typed handler arguments out of this; application code rarely touches it directly. - Param
Def - The compile-time description of one route parameter, recorded by the
routes!macro and used to extract and parse it at request time. - Params
- Raw parameters from the HTTP request, plus headers, the parsed body, and a typed extensions slot for per-request data that prepare hooks (or middleware) want to attach for handlers to read.
- Problem
Details - Structured error response shaped like an RFC 7807 Problem Details document, plus arbitrary extension members that get serialized into the JSON body.
- Reply
Spec - A builder for a reply with an explicit status and/or headers wrapped
around a payload. Start one with
build_reply, chain the setters, and finish withReplySpec::done(which yields aReplyData::Rich). - Route
Def - The compile-time description of one route in a controller, recorded by the
routes!macro. The framework matches and dispatches against these, and tools can introspect them (e.g. the OpenAPI generator). - SseEvent
- One frame in a Server-Sent Events stream. A frame may carry data
(the common case), a comment (heartbeats and debug pings), and the
optional
event/id/retryfields. The wire encoding is handled bySseEvent::to_bytes— embedded newlines indatabecome multipledata:lines, the way the spec requires. - Status
Code - An HTTP status code (
status-codein RFC 9110 et al.).
Enums§
- Controller
Mode - How a controller treats request parameters it didn’t declare.
- Param
Default - A parameter’s default value, applied when the request omits it. Declared
in
routes!asname: Type = default. - Param
Source - Where a parameter’s value is read from.
- Param
Type - The declared type of a route parameter — governs how its raw string value is parsed before reaching the handler.
- Reply
Data - The concrete payload of a successful reply. The
Finalizerturns it into an HTTP response. Build one with thereply!macro or thereply::*constructor functions rather than by hand. - Verb
- An HTTP method. Used in
routes!verb prefixes and for theAllowheader the framework stamps on405responses. - WebError
- An error returned from a handler, a
preparehook, or middleware. Each variant maps to an HTTP status the framework renders as the response (WebError::Problemas anapplication/problem+jsonbody).
Constants§
- DEFAULT_
VERBS - Verbs accepted by a route declared without a verb prefix. Reflects the “verbs are constraints, not identities” stance: an unmarked route imposes no semantic restriction beyond what HTML forms emit natively. Restrictive verbs (PUT/DELETE/PATCH) and protocol verbs (HEAD/OPTIONS) must be opted into explicitly.
Traits§
- Controller
- The runtime interface every controller implements. Hand-writing this is
possible but unusual — the
#[controller]macro generates the implementation (dispatch table, parameter extraction, the metadata methods) from a controller’simplblock and itsroutes!declaration.
Functions§
- build_
reply - Start a
ReplySpecbuilder for a reply that needs an explicit status and/or headers on top of its body. - bytes
- Build a
ReplyData::Byteswith an explicitContent-Type. The content-type is required: there is no honest default for arbitrary bytes, andapplication/octet-streammasquerading as one tends to cause more bugs than it fixes (browsers guess; downstream HTTP caches mis-cache). Pass the right media type at the call site. - empty
- An empty-body reply (
204 No Contentunless a status is set viabuild_reply). - json
- Build a JSON
ReplyDatafrom anySerializevalue. - sse
- Build a streaming Server-Sent Events response from a stream of
SseEvents. SetsContent-Type: text/event-streamandCache-Control: no-cache(without which an intermediate cache might hold the live stream, defeating the point). - stream
- Build a streaming-body reply from a stream of byte chunks. The body is written out as the stream yields, not buffered.
- try_
json - Fallible counterpart of
json. Returns the rawserde_json::Erroron failure so callers (notably thereply!macro) can map it to a structured response instead of panicking.
Type Aliases§
- Body
Stream - A boxed,
Send + Syncstream of body chunks, used byReplyData::Streamand SSE responses. - Reply
- A handler’s return type:
Ok(ReplyData)for a success payload, orErr(WebError)for an error the framework renders as an HTTP error response. Thereply!macro produces theOkside. - Routes
- A list of
(mount, controller-factory)pairs — the route-registration shape theapp_routes!macro builds when wiring controllers into a router.
Attribute Macros§
- async_
trait - controller
- Attribute macro for a controller’s
implblock.