Skip to main content

Module forward

Module forward 

Source
Expand description

§Forward

§Purpose

Provides utilities for constructing HTTP responses from gRPC messages. This module bridges the gap between the gRPC client’s output (Protobuf messages or streams) and the HTTP server’s response format (bytes).

§Scope

This module exposes functions to:

  • forward_response_message: Convert a single gRPC message into a unary HTTP response.
  • forward_response_stream: Convert a stream of gRPC messages into a single aggregated HTTP response.

§Position in the Architecture

These functions are called by the code generated by gateway-codegen at the end of a request handler. They take the result from the gRPC client, encode it using the specified Codec, and wrap it in an http::Response.

§Design Constraints

  • Codec Agnostic: Functions are generic over Codec, allowing them to work with any supported wire format.
  • Buffered Responses: Currently aggregates streaming responses into a single byte vector to simplify the return type.

Functions§

forward_response_message
Constructs an HTTP response from a single gRPC message.
forward_response_stream
Constructs an HTTP response from a gRPC stream.