Fix typo in extract::ws (#1664)

Co-authored-by: David Pedersen <david.pdrsn@gmail.com>
This commit is contained in:
Michael Scofield 2023-02-24 22:35:31 +01:00 committed by David Pedersen
parent 3ba74aa2f5
commit 9be0ea934c
2 changed files with 13 additions and 10 deletions

View file

@ -8,8 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
# Unreleased
- **breaking:** Change `sse::Event::json_data` to use `axum_core::Error` as its error type ([#1762])
- **breaking:** Rename `DefaultOnFailedUpdgrade` to `DefaultOnFailedUpgrade` ([#1664])
- **breaking:** Rename `OnFailedUpdgrade` to `OnFailedUpgrade` ([#1664])
[#1762]: https://github.com/tokio-rs/axum/pull/1762
[#1664]: https://github.com/tokio-rs/axum/pull/1664
# 0.6.16 (18. April, 2023)

View file

@ -135,7 +135,7 @@ use tokio_tungstenite::{
///
/// See the [module docs](self) for an example.
#[cfg_attr(docsrs, doc(cfg(feature = "ws")))]
pub struct WebSocketUpgrade<F = DefaultOnFailedUpdgrade> {
pub struct WebSocketUpgrade<F = DefaultOnFailedUpgrade> {
config: WebSocketConfig,
/// The chosen protocol sent in the `Sec-WebSocket-Protocol` header of the response.
protocol: Option<HeaderValue>,
@ -268,7 +268,7 @@ impl<F> WebSocketUpgrade<F> {
/// ```
pub fn on_failed_upgrade<C>(self, callback: C) -> WebSocketUpgrade<C>
where
C: OnFailedUpdgrade,
C: OnFailedUpgrade,
{
WebSocketUpgrade {
config: self.config,
@ -287,7 +287,7 @@ impl<F> WebSocketUpgrade<F> {
where
C: FnOnce(WebSocket) -> Fut + Send + 'static,
Fut: Future<Output = ()> + Send + 'static,
F: OnFailedUpdgrade,
F: OnFailedUpgrade,
{
let on_upgrade = self.on_upgrade;
let config = self.config;
@ -339,12 +339,12 @@ impl<F> WebSocketUpgrade<F> {
/// What to do when a connection upgrade fails.
///
/// See [`WebSocketUpgrade::on_failed_upgrade`] for more details.
pub trait OnFailedUpdgrade: Send + 'static {
pub trait OnFailedUpgrade: Send + 'static {
/// Call the callback.
fn call(self, error: Error);
}
impl<F> OnFailedUpdgrade for F
impl<F> OnFailedUpgrade for F
where
F: FnOnce(Error) + Send + 'static,
{
@ -353,20 +353,20 @@ where
}
}
/// The default `OnFailedUpdgrade` used by `WebSocketUpgrade`.
/// The default `OnFailedUpgrade` used by `WebSocketUpgrade`.
///
/// It simply ignores the error.
#[non_exhaustive]
#[derive(Debug)]
pub struct DefaultOnFailedUpdgrade;
pub struct DefaultOnFailedUpgrade;
impl OnFailedUpdgrade for DefaultOnFailedUpdgrade {
impl OnFailedUpgrade for DefaultOnFailedUpgrade {
#[inline]
fn call(self, _error: Error) {}
}
#[async_trait]
impl<S> FromRequestParts<S> for WebSocketUpgrade<DefaultOnFailedUpdgrade>
impl<S> FromRequestParts<S> for WebSocketUpgrade<DefaultOnFailedUpgrade>
where
S: Send + Sync,
{
@ -407,7 +407,7 @@ where
sec_websocket_key,
on_upgrade,
sec_websocket_protocol,
on_failed_upgrade: DefaultOnFailedUpdgrade,
on_failed_upgrade: DefaultOnFailedUpgrade,
})
}
}