pub struct Router<S> { /* private fields */ }Expand description
The request dispatcher.
Maps (HTTP Method) -> List of (Pattern, Service, Metadata).
§Type Parameters
S: The type of the service handler. This is typicallyBoxCloneServiceor similar.
Implementations§
Source§impl<S> Router<S>
impl<S> Router<S>
Sourcepub fn match_request(
&self,
method: &Method,
path: &str,
) -> Option<(&S, BTreeMap<String, String>, &RouteMetadata)>
pub fn match_request( &self, method: &Method, path: &str, ) -> Option<(&S, BTreeMap<String, String>, &RouteMetadata)>
Matches an incoming request against registered routes.
§Parameters
method: The HTTP method of the request.path: The request path.
§Returns
An Option containing a tuple if a match is found:
&S: A reference to the matched service.BTreeMap<String, String>: A map of captured path variables (e.g.,idfrom/users/{id}).&RouteMetadata: Metadata associated with the matched route.
Trait Implementations§
Auto Trait Implementations§
impl<S> Freeze for Router<S>
impl<S> RefUnwindSafe for Router<S>where
S: RefUnwindSafe,
impl<S> Send for Router<S>where
S: Send,
impl<S> Sync for Router<S>where
S: Sync,
impl<S> Unpin for Router<S>
impl<S> UnwindSafe for Router<S>where
S: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request