1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! Server-Sent Events (SSE) support
//!
//! ## Server-Sent Events (SSE)
//!
//! Server-Sent Events (SSE) is a simple and efficient mechanism for servers to push real-time updates to
//! clients over HTTP. Unlike WebSockets, which provide full-duplex communication,
//! SSE establishes a one-way channel from server to client using a long-lived HTTP connection.
//!
//! Rama offers support for `SSE` both as a client and a server.
//! As such you could even MITM proxy it.
//!
//! Server `IntoResponse` support is also supported, including with `Keep-Alive` support.
//! See <https://ramaproxy.org/docs/rama/http/service/web/response/struct.Sse.html> for more info.
//!
//! Learn more about SSE at <https://ramaproxy.org/book/sse.html>.
//!
//! ## Examples
//!
//! You can find ready-to-run examples demonstrating how to expose and consume SSE endpoints using Rama:
//!
//! - [`http_sse.rs`](https://github.com/plabayo/rama/blob/main/examples/http_sse.rs)
//! Simple example showing how to expose an SSE endpoint with string data.
//! - [`http_sse_json.rs`](https://github.com/plabayo/rama/blob/main/examples/http_sse_json.rs)
//! Same as above, but emits **structured JSON data** using typed Rust structs.
//!
//! These examples make use of Rama's typed header support, such as [`LastEventId`](https://github.com/plabayo/rama/blob/main/rama-http-headers/src/common/last_event_id.rs), which allows easy extraction of reconnect state to resume streams reliably.
//!
//! ## Datastar
//!
//! > Datastar helps you build reactive web applications with the simplicity of server-side rendering and the power of a full-stack SPA framework.
//! >
//! > — <https://data-star.dev/>
//!
//! Rama has built-in support for [🚀 Datastar](https://data-star.dev).
//! You can see it in action in [Examples](https://github.com/plabayo/rama/tree/main/examples):
//!
//! - [/examples/http_sse_datastar_hello.rs](https://github.com/plabayo/rama/tree/main/examples/http_sse_datastar_hello.rs):
//! SSE Example, showcasing a very simple datastar example,
//! which is supported by rama both on the client as well as the server side.
//!
//! Rama rust docs:
//!
//! - SSE support: [datastar]
//! - Extractor support (`ReadSignals`): <https://ramaproxy.org/docs/rama/http/service/web/extract/datastar/index.html>
//! - Embedded JS Script: <https://ramaproxy.org/docs/rama/http/service/web/response/struct.DatastarScript.html>
//!
//! ## Code Origins
//!
//! Some code in this repo is adapted from third party sources:
//! - Axum (see <https://github.com/plabayo/rama/blob/main/docs/thirdparty/fork/README.md#relative-forks>)
//! - <https://github.com/jpopesculian/eventsource-stream/tree/3d46f1c758f9ee4681e9da0427556d24c53f9c01>:
//! - Licensed under MIT OR Apache-2.0, owned by Julian Popescu <jpopesculian@gmail.com>
pub use ;