mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-21 00:00:14 +02:00
Add KeepAlive::event (#1729)
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user