Skip to main content

Module input_ext

Module input_ext 

Available on crate feature net only.
Expand description

Small, single-concern accessor traits for reading routing/transport properties off a service input (an http request, a connect target, …).

Each concern (URI, path, authority, protocol, http version, transport) is its own small trait, so a caller reads exactly the piece it needs instead of building a combined context up front.

Design (matching ClientIp): each resolution trait has no ExtensionsRef bound and is never blanket-derived from another trait — every input type opts in with the resolution that fits it (the http Request/Parts impls in rama-http-types walk the Forwarded → uri → Host → TLS SNI chain, their target view skips Forwarded; a transport target resolves its authority directly). The only blanket impls are the trivial reference-forwarding ones and the composed connector accessors, whose methods are purely derived.

The return type is the fallibility contract: an Option may be absent (a caller that requires it does .ok_or_else(|| …)? with its own error); transport_protocol is always known, so it returns a bare value.

Each resolution trait also carries default methods built on its one required accessor (e.g. AuthorityInputExt::host_as_domain), so callers get ergonomic projections without re-writing the same closure chains.

§Which one to use

An HTTP request has two views of its target resource (RFC 9110 §7.1). The plain accessors, authority and protocol, say what the end client asked for and may come from Forwarded context: use them for routing, policy and logs. The target_* ones, target_authority and target_protocol, say what this hop dials, names in TLS SNI and keys its connection pool by, and never read forwarded context. http_version and target_http_version split the same way.

Traits§

AuthorityInputExt
Read the routing authority (host[:port]) of a service input.
ConnectorTargetInputExtstd
Resolve the transport address (host:port) to connect to: the routing authority with the application protocol’s default port as the port fallback.
ConnectorTransportProtocolInputExtstd
Resolve the physical transport protocol a connector should establish.
HttpVersionInputExtstd
Read the contextual HTTP Version of a service input.
PathInputExt
Read the URI path of a service input.
ProtocolInputExt
Read the application-layer Protocol (scheme) of a service input.
TargetHttpVersionInputExtstd
Read the target HTTP Version a connector should establish.
TransportProtocolInputExt
Read the transport-layer TransportProtocol (TCP/UDP) of a service input.
UriInputExt
Read the Uri of a service input that carries one.