Expand description
Request model binding — the runtime half of #[derive(WebxRequestMeta)].
A request struct declares where each field comes from (#[frompath],
#[fromquery], #[frombody], #[fromform], #[fromheader],
#[fromclaim]). The derive compiles that declaration into a
RequestModel::bind implementation; this module provides the value
providers and coercion helpers that implementation calls.
§Why not serde for query/path/header/claim
HTTP values are strings, often repeated (?id=1&id=2), and a failure in
one field must not hide the others. serde_json models documents, not HTTP
values, so it cannot coerce "2" into u32, cannot represent repeated keys,
and fails at the first error. Here every scalar is parsed with FromStr,
lists keep every occurrence, and failures accumulate in a Binder so the
response can report all of them at once.
JSON bodies stay with serde: the derive generates a hidden body struct
containing only the body-bound fields, so rename, flatten, default and
custom deserializers keep working exactly as written.
Structs§
- Bind
Input - The value providers a generated
RequestModel::bindreads from. - Binder
- Accumulates field-level binding failures into one 400 response.
Enums§
- Source
- Where a request field’s value comes from.
Traits§
- Request
Model - A type that can be constructed from an HTTP request.
Functions§
- body_
error - Convert a JSON body deserialization failure into a field-level 400.
- body_
field_ error - A field-level body failure: the JSON key was present but its value did not match the field type.
- is_
body_ method - Whether
methodcarries a JSON body by default (ASP.NET Core’s rule). - split_
csv - Expand one optional raw value into a list, splitting on commas.
- take_
body_ field - Remove
key(or one ofaliases) from a JSON object.