Expand description
gRPC support for HttpServer.
There is no dedicated gRPC server here, because gRPC does not need one: it is HTTP/2 plus a route naming
convention (/<package>.<Service>/<Method>) and a trailer-carried status code. tonic’s Routes is an
axum::Router underneath, and HttpServer already serves HTTP/2, so a gRPC service
is served by handing its routes to an HttpServer like any other route set.
What that leaves are the parts route matching can’t cover on its own: a request that matches nothing has to be
answered in whichever protocol the caller spoke, and a request that carries a deadline has to be held to it.
merge_grpc_routes wires up both.
Most callers never reach for this module directly. Handing services to
HttpServer::add_grpc_service applies all of it:
let _server = HttpServer::from_listen_address(listen_address)
.add_grpc_service(service)
.with_http2_only()
.with_http2_config(Http2Config::grpc_defaults());merge_grpc_routes is for callers that build their own router up-front and hand it over with
HttpServer::with_routes, rather than accumulating routes on the server.
Structs§
- Grpc
Timeout - A
Servicethat bounds how long the inner service has to answer a gRPC request. - Grpc
Timeout Future - Response future for
GrpcTimeout. - Grpc
Timeout Layer - A
Layerthat holds a gRPC request to the deadline it arrived with.
Functions§
- is_
grpc_ request - Returns
trueif the given headers indicate a gRPC request. - merge_
grpc_ routes - Merges gRPC routes into an HTTP router.
- unmatched_
route - Answers a request that matched no route, in the protocol the caller used.