Skip to main content

handle_upgrade

Function handle_upgrade 

pub fn handle_upgrade<T>(
    msg: T,
) -> impl Future<Output = Result<Upgraded, Box<dyn Error + Send + Sync>>> + 'static
where T: ExtensionsRef,
Available on crate feature http only.
Expand description

Gets a pending HTTP upgrade from this message and handles it.

This can be called on types implementing ExtensionsRef:

Some notable examples are:

  • http::Request<B>
  • http::Response<B>
  • &rama_http::Request<B>
  • &rama_http::Response<B>

When the upgrade completes, the returned Upgradeds Extensions are reparented to the message that triggered it: upgraded.parent = msg.fork(). That gives the upgraded a fresh top-level storage of its own while keeping everything the message could see: both HTTP-level state on the message itself and connection-level state reachable through the message’s Ingress / Egress wrappers