Skip to main content

bind_form_request

Function bind_form_request 

Source
pub async fn bind_form_request<T>(
    ctx: &mut dyn IHttpContext,
) -> Result<Option<T>, Error>
where T: DeserializeOwned + Send + 'static,
Expand description

Bind T from a multipart/form-data body.

Returns Ok(None) when the request does not declare Content-Type: multipart/form-data, so the caller can fall back to JSON or parameter binding.

Route parameters are merged into the form as text values, so POST /api/users/{id}/avatar binds {id} alongside the uploaded file. Binding failures are reported as Error::Validation (HTTP 400) with the offending field named.