Skip to content

Commit

Permalink
Fix typo in extract::ws (#1664)
Browse files Browse the repository at this point in the history
Co-authored-by: David Pedersen <[email protected]>
  • Loading branch information
mscofield0 and davidpdrsn committed Feb 24, 2023
1 parent f8ba531 commit fc1a10f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
3 changes: 3 additions & 0 deletions axum/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- **changed:** Update to tower-http 0.4. axum is still compatible with tower-http 0.3
- **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.8 (24. February, 2023)

Expand Down
20 changes: 10 additions & 10 deletions axum/src/extract/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down Expand Up @@ -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,
Expand All @@ -290,7 +290,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;
Expand Down Expand Up @@ -342,12 +342,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,
{
Expand All @@ -356,20 +356,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,
{
Expand Down Expand Up @@ -410,7 +410,7 @@ where
sec_websocket_key,
on_upgrade,
sec_websocket_protocol,
on_failed_upgrade: DefaultOnFailedUpdgrade,
on_failed_upgrade: DefaultOnFailedUpgrade,
})
}
}
Expand Down

0 comments on commit fc1a10f

Please sign in to comment.