pub struct FromJson<T: ApiBody>(pub T);
Expand description
If the last argument to a handler is this, we’ll assume
that the user needs to provide JSON that decodes to T
.
Notably, T
needs to implement ApiBody
with the
Deserialize option.
Tuple Fields§
§0: T
Trait Implementations§
source§impl<T> ApiBody for FromJson<T>where
T: ApiBody,
impl<T> ApiBody for FromJson<T>where
T: ApiBody,
source§fn api_body_info() -> ApiBodyInfo
fn api_body_info() -> ApiBodyInfo
This returns information about the shape of the type and description of parts of it.
source§impl<T: DeserializeOwned + ApiBody> HandlerBody for FromJson<T>
impl<T: DeserializeOwned + ApiBody> HandlerBody for FromJson<T>
source§fn handler_body<'life0, 'async_trait>(
req: Request<&'life0 mut dyn AsyncReadBody>
) -> Pin<Box<dyn Future<Output = Result<Self, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn handler_body<'life0, 'async_trait>(
req: Request<&'life0 mut dyn AsyncReadBody>
) -> Pin<Box<dyn Future<Output = Result<Self, ApiError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Given a request containing arbitrary bytes, this function needs to return an
instance of the type that this trait is implemented on (typically by deserializing
it from the bytes provided), or else it should return an error describing what
went wrong.
source§fn handler_method() -> Method
fn handler_method() -> Method
Which HTTP method is required for this Body to be valid. By default, if a body
is present in the handler we’ll expect the method to be POST. Implement this function
to override that.