mirror of
https://github.com/tokio-rs/axum.git
synced 2024-12-29 15:49:16 +01:00
Document browsers ignoring SSE events without data fields (#1242)
* Document browsers ignoring SSE events without data fields * only add note on `Event::data`
This commit is contained in:
parent
9b44654c86
commit
c72ee6eca9
1 changed files with 5 additions and 3 deletions
|
@ -175,12 +175,14 @@ impl Event {
|
|||
///
|
||||
/// This corresponds to [`MessageEvent`'s data field].
|
||||
///
|
||||
/// [`MessageEvent`'s data field]: https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
|
||||
/// Note that events with an empty data field will be ignored by the browser.
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// - Panics if `data` contains any carriage returns, as they cannot be transmitted over SSE.
|
||||
/// - Panics if `data` or `json_data` have already been called.
|
||||
///
|
||||
/// [`MessageEvent`'s data field]: https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
|
||||
pub fn data<T>(mut self, data: T) -> Event
|
||||
where
|
||||
T: AsRef<str>,
|
||||
|
@ -202,11 +204,11 @@ impl Event {
|
|||
///
|
||||
/// This corresponds to [`MessageEvent`'s data field].
|
||||
///
|
||||
/// [`MessageEvent`'s data field]: https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
|
||||
///
|
||||
/// # Panics
|
||||
///
|
||||
/// Panics if `data` or `json_data` have already been called.
|
||||
///
|
||||
/// [`MessageEvent`'s data field]: https://developer.mozilla.org/en-US/docs/Web/API/MessageEvent/data
|
||||
#[cfg(feature = "json")]
|
||||
pub fn json_data<T>(mut self, data: T) -> serde_json::Result<Event>
|
||||
where
|
||||
|
|
Loading…
Reference in a new issue