mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-29 07:48:39 +01:00
Add KeepAlive::event
(#1729)
This commit is contained in:
parent
1f224396a2
commit
2cbaa63d9e
2 changed files with 17 additions and 3 deletions
|
@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
# Unreleased
|
||||
|
||||
- **fixed:** Fix `Allow` missing from routers with middleware
|
||||
- **added:** Add `KeepAlive::event` for customizing the event sent for SSE keep alive ([#1729])
|
||||
|
||||
[#1729]: https://github.com/tokio-rs/axum/pull/1729
|
||||
|
||||
# 0.6.7 (17. February, 2023)
|
||||
|
||||
|
|
|
@ -409,16 +409,27 @@ impl KeepAlive {
|
|||
///
|
||||
/// Default is an empty comment.
|
||||
///
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `text` contains any newline or carriage returns, as they are not allowed in SSE
|
||||
/// comments.
|
||||
pub fn text<I>(mut self, text: I) -> Self
|
||||
pub fn text<I>(self, text: I) -> Self
|
||||
where
|
||||
I: AsRef<str>,
|
||||
{
|
||||
self.event = Event::default().comment(text).finalize();
|
||||
self.event(Event::default().comment(text))
|
||||
}
|
||||
|
||||
/// Customize the event of the keep-alive message.
|
||||
///
|
||||
/// Default is an empty comment.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `event` contains any newline or carriage returns, as they are not allowed in SSE
|
||||
/// comments.
|
||||
pub fn event(mut self, event: Event) -> Self {
|
||||
self.event = event.finalize();
|
||||
self
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue