Skip to main content

forward_response_stream

Function forward_response_stream 

Source
pub async fn forward_response_stream<S, T, C>(
    codec: &C,
    stream: S,
    req: &GatewayRequest,
) -> Result<Response<BoxBody>, GatewayError>
where S: Stream<Item = Result<T, Status>> + Send + 'static, T: Message + Serialize, C: Codec + Clone + Send + Sync + 'static,
Expand description

Constructs an HTTP response from a gRPC stream.

This function collects all items from the stream, encodes them, and aggregates them into a single byte vector.

Note: This implementation buffers the entire stream in memory. This is a simplification to ensure compatibility with tower::Service return types that expect a concrete body type.

§Parameters

  • codec: The codec used to encode stream items.
  • stream: The incoming gRPC stream.
  • req: The incoming request (used to determine Accept header).

§Returns

A Result containing the HTTP response with the aggregated body, or a GatewayError if processing fails.