gateway-runtime 0.1.1

Runtime library for the Rust gRPC Gateway.
docs.rs failed to build gateway-runtime-0.1.1
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.

Gateway Runtime

Purpose

This module provides the runtime support library for the gRPC Gateway. It contains the essential components required by the generated code to bridge HTTP/JSON requests to gRPC services. This includes routing logic, message serialization/deserialization (transcoding), metadata translation, and error handling.

Scope

This module is responsible for:

  • Routing: Matching incoming HTTP requests to registered gRPC service methods using the Router.
  • Transcoding: Converting between HTTP body formats (e.g., JSON) and Protocol Buffers using the Codec trait.
  • Forwarding: Translating HTTP headers to gRPC metadata and invoking the underlying gRPC client.
  • Error Handling: Mapping gRPC status codes to appropriate HTTP status codes and response bodies.

Position in the Architecture

The gateway-runtime crate serves as the foundation for the code generated by gateway-codegen. Generated service registrations import and utilize the types and functions defined here. It acts as the middleware layer between the HTTP server (e.g., hyper) and the gRPC client (e.g., tonic).

Design Constraints

  • no_std Support: The library is designed to support no_std environments by relying on the alloc crate and conditionally compiling std-dependent features.
  • Type Safety: It leverages Rust's type system to ensure correct mapping between HTTP and gRPC types.
  • Extensibility: The Codec and Router abstractions allow for plugging in different serialization formats and routing strategies.