Skip to main content

RouterExt

Trait RouterExt 

pub trait RouterExt<State, L, O, E>: Sealed {
    // Required methods
    fn with_grpc_service<S>(self, service: S) -> Self
       where S: Service<Request> + NamedService,
             L: Layer<S>,
             <L as Layer<S>>::Service: Service<Request, Output = O, Error = E>;
    fn set_grpc_service<S>(&mut self, service: S) -> &mut Self
       where S: Service<Request> + NamedService,
             L: Layer<S>,
             <L as Layer<S>>::Service: Service<Request, Output = O, Error = E>;
}
Available on crate features grpc and http and std only.
Expand description

Sealed extension methods for registering generated gRPC services on a web Router.

Import this trait to make RouterExt::with_grpc_service and RouterExt::set_grpc_service available on Router. The route is derived from NamedService::NAME and preserves the canonical gRPC request URI: /<package>.<Service>/<Method>.

Required Methods§

fn with_grpc_service<S>(self, service: S) -> Self
where S: Service<Request> + NamedService, L: Layer<S>, <L as Layer<S>>::Service: Service<Request, Output = O, Error = E>,

Register a generated gRPC service and return the updated router.

gRPC requests use POST /<service-name>/<method>. Unlike mounting a nested service, this route does not strip the service name from the URI before forwarding the request.

fn set_grpc_service<S>(&mut self, service: S) -> &mut Self
where S: Service<Request> + NamedService, L: Layer<S>, <L as Layer<S>>::Service: Service<Request, Output = O, Error = E>,

Register a generated gRPC service on this router.

gRPC requests use POST /<service-name>/<method>. Unlike mounting a nested service, this route does not strip the service name from the URI before forwarding the request.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

§

impl<State, L, O, E> RouterExt<State, L, O, E> for Router<State, L, O, E>
where State: Send + Sync + Clone + 'static,