pub trait BodyProtocolRouter:
Send
+ Sync
+ Debug {
// Required method
fn claim(&self, request: &Request<()>) -> BodyRouteClaim;
// Provided methods
fn claim_with_body(&self, request: &Request<CollectedBody>) -> RouteClaim { ... }
fn route_with_body(
&self,
request: &Request<CollectedBody>,
) -> Result<OperationTarget, RoutingError> { ... }
}Expand description
Routes operations using the request head and, when needed, the complete body.
claim checks the head first. After Claimed or NeedsBodyToClaim,
the service collects the body under ServiceRequestBodyConfig::for_routing
and preserves it for later routers and the handler. Decline from the head when
possible to avoid waiting for a body the client may never send.
Body routers exclude streaming operations. If any metadata router recognizes
streaming input, NeedsBodyToClaim is skipped; head claims retain priority.
Routing errors are terminal and serialized by the claiming protocol. Without a definite claim, the first deferred claim is dispatched. An unclaimed request uses the first deferred rejection, if any, or the service’s protocol-neutral response, including for a single-protocol service.
Required Methods§
Sourcefn claim(&self, request: &Request<()>) -> BodyRouteClaim
fn claim(&self, request: &Request<()>) -> BodyRouteClaim
Checks the request head, requesting body collection if needed.
Provided Methods§
Sourcefn claim_with_body(&self, request: &Request<CollectedBody>) -> RouteClaim
fn claim_with_body(&self, request: &Request<CollectedBody>) -> RouteClaim
Continues a BodyRouteClaim::NeedsBodyToClaim decision with the complete body.
Returning Claimed proceeds to Self::route_with_body.
Sourcefn route_with_body(
&self,
request: &Request<CollectedBody>,
) -> Result<OperationTarget, RoutingError>
fn route_with_body( &self, request: &Request<CollectedBody>, ) -> Result<OperationTarget, RoutingError>
Selects an operation after BodyRouteClaim::Claimed or RouteClaim::Claimed.
Errors are terminal and serialized by this protocol.