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
use crate::*;
/// Shared application state.
///
/// Holds the generated HTML, reload channel, build lock, and CLI arguments
/// for coordination between the HTTP server and file watcher.
/// Request middleware that injects cache-control headers.
///
/// Sets `Cache-Control: no-cache, no-store, must-revalidate`, `Pragma: no-cache`,
/// and `Expires: 0` on every response to prevent stale WASM assets during development.
;
/// Response middleware that writes the serialized response to the stream.
///
/// Builds the HTTP response bytes and sends them through the connection stream,
/// closing the stream if the send fails.
;
/// Route handler for the root path serving the injected development HTML.
///
/// When the request targets `index.html`, returns the in-memory HTML
/// that has the live-reload script injected. For all other files,
/// reads the content from disk with path-traversal protection.
;
/// Route handler for the reload endpoint using long-polling.
///
/// Holds the connection open until a reload event is broadcast, then returns
/// a single JSON response so the client can distinguish between a successful
/// rebuild and an error.
;