Skip to main content

forward_response_message

Function forward_response_message 

Source
pub fn forward_response_message<T: Message + Serialize, C: Codec>(
    codec: &C,
    msg: &T,
    req: &GatewayRequest,
) -> Result<Response<BoxBody>, GatewayError>
Expand description

Constructs an HTTP response from a single gRPC message.

This function encodes the message using the provided codec and builds a standard HTTP 200 OK response with the appropriate Content-Type.

§Parameters

  • codec: The codec used to encode the message.
  • msg: The gRPC message to send.
  • req: The incoming request (used to determine Accept header).

§Returns

A Result containing the HTTP response with the encoded body, or a GatewayError if encoding fails.