Extractors
Handler parameters that read the call, checked when the application is built.
An extractor is a handler parameter whose type says what to read from the call. Path<u32> parses a route segment, Json<T> deserialises a body, Multipart streams an upload. The generated handler extracts every parameter in order, then builds the controller, then runs the method. A failed extraction builds no per-execution controller (a controller built once per call, see Scopes) and answers an error before the handler body runs, so the body never validates its own inputs.
A parameter comes from one of two places:
- From the call: types that implement
FromCall<T>for a transportT. The HTTP ones are in this chapter and are imported fromulo_http. - From the container:
Dep<T>,Ext<T>,ExecutionRefand the other injection-point types. They are accepted on every transport; see Core Concepts.
One rule governs the body: a request has one, and only one extractor may read it. Each type declares whether it consumes the body, and the macro checks every pair of parameters at compile time, naming both in the error. An alias such as type Body<T> = Json<T> is checked as the type it names.
FromCall is generic over the transport, so the same shape extracts an RPC payload or a WebSocket frame; Custom Extractors shows one written for HTTP. The examples for this chapter are examples/15-http-requests and examples/19-http-uploads.
Built-in Extractors
Path, Query, Json, Form, Header, Bytes, BodyStream, and what each does when the call does not fit.
Validation
Valid<P> and the rules that turn a decoded value into a 422.
Custom Extractors
Implementing FromCall for a type of your own, and failing with the right error.
Multipart
Streaming uploads under a server body limit and a per-route one.