Skip to main content

parse_body

Function parse_body 

Source
pub async fn parse_body<T, C>(
    headers: &HeaderMap,
    body: Vec<u8>,
    codec: &C,
) -> Result<T, GatewayError>
Expand description

Parses the request body into a Protobuf message.

This function handles:

  • application/json: Decodes using the provided codec.
  • multipart/form-data: Parses multipart parts and maps them to the message fields.

§Parameters

  • headers: The request headers.
  • body: The request body as bytes.
  • codec: The codec to use for decoding.

§Returns

A Result containing the parsed message or a GatewayError.