#3688·axum

Support testing of websocket routes

Author: bjorn3Created Mar 11, 2026Updated Mar 12, 2026
  • I have looked for existing issues (including closed) about this

Feature Request

Motivation

For regular routes you can test them without listening on any tcp port using router.oneshot(Request::builder()...). For websockets however the WebSocketUpgrade extractor needs the hyper::upgrade::OnUpgrade extension which does not have a public constructor. Adding one has been rejected by hyper in https://github.com/hyperium/hyper/issues/4034.

Proposal

Create an alternative to OnUpgrade that has a public constructor accepting an AsyncRead + AsyncWrite object that can be added as extension to a Request which is checked by WebSocketUpgrade if there is no hyper::upgrade::OnUpgrade extension.

Alternatives

Locally patch hyper to make the OnUpgrade constructor public. This would effectively require vendoring hyper to be able to run in CI and make it impossible to publish the project in question to crates.io.