Skip to main content

BodyProtocolRouter

Trait BodyProtocolRouter 

Source
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§

Source

fn claim(&self, request: &Request<()>) -> BodyRouteClaim

Checks the request head, requesting body collection if needed.

Provided Methods§

Source

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.

Source

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.

Implementors§