Expand description
§Router
§Purpose
The Router module provides the core mechanism for dispatching incoming HTTP requests to
the appropriate gRPC service handlers based on path patterns and HTTP methods.
§Overview
It maintains a registry of routes, where each route consists of:
- An HTTP Method (e.g., GET, POST).
- A compiled Pattern (from
gateway_internal::path_template). - A service handler (
S) responsible for processing the request. - RouteMetadata, containing additional configuration like authentication requirements.
§Matching Logic
When match_request is called, the router iterates through the registered patterns for the
given HTTP method. It uses the gateway_internal matching engine to determine if the
request path matches a pattern. If a match is found, it returns the service, any captured
path variables, and the route metadata.
§Usage
The router is typically populated by generated code calling route or route_with_metadata.
At runtime, it is wrapped by the Gateway service.
Structs§
- Auth
Config - Configuration for API Key authentication.
- Route
Metadata - Metadata associated with a route configuration.
- Router
- The request dispatcher.
Enums§
- Auth
Location - The location of the authentication credential.
Functions§
- route
- Registers a service with the router using default metadata.
- route_
with_ metadata - Registers a service with the router, including specific metadata.