Module sse

Module sse 

Source
Available on crate feature sse only.
Expand description

Async SSE.

This adds some wrappers around using the async-sse crate with this HTTP library, making it easier to handle SSE connections. It is gated behind the sse feature flag for those who do not want to use it.

Structs§

Sender
The sending side of the encoder.
SseEndpoint
An instance of an SSE endpoint.

Functions§

endpoint
Creates an endpoint that can handle SSE connections. This directly upgrades the HTTP request to SSE unconditionally, before calling the handler function with the current request and the SSE sender.
stream_heartbeat
Performs a heartbeat on an SSE connection. This allows the server to ensure that a client is still connected. This is expected, generally, to be used in conjunction with either endpoint or upgrade. The steam passed in should be cancellable, and will be cancelled if it does not resolve within the heartbeat timeout (1s by default). This is mostly expected to be used in a loop.
upgrade
Upgrades a request to SSE. This allows you to check beforehand if a request should be upgraded to SSE, instead of endpoint, which directly upgrades the connection.