06 / EDGE
files
A file-serving layer over an in-memory set: a GET under a prefix whose remaining path names a registered file is answered with it, with a content-derived ETag and a 304 for a conditional request. The bytes live in a value, so a test serves a file it built and a deployment loads a directory once.
WHERE IT SITS
INTERFACE
struct FileEntrystructOne servable file: its bytes and the media type it is announced with. The ETag is derived from the content, so a conditional request works without the loader having to know a modification time.
struct FilesstructThe files a service serves, keyed by path relative to the mount prefix.
fn Files::new() -> FilesfnAn empty set of files.
fn Files::add( self : Files, path : String, body : Bytes, media_type? : String) -> UnitfnAdd body under path (/logo.svg, say). The media type is guessed from the extension unless one is given.
fn Files::get(self : Files, path : String) -> FileEntry?fnThe file registered under path, or None.
fn Files::paths(self : Files) -> Array[String]fnThe paths in this set, sorted, so a listing or a test is stable.
fn media_type_of(path : String) -> StringfnThe media type for a path, from its extension. The table covers the types a static bundle actually carries; anything else is served as application/octet-stream, which every client downloads rather than guesses.
fn FileEntry::etag(self : FileEntry) -> StringfnThe ETag of a file: a quoted, strong validator derived from the length and a CRC-32 of the bytes, so two builds that produce the same content serve the same tag.
fn file_server(files : Files, prefix : String) -> MiddlewarefnThe file-serving layer: a GET under prefix whose remaining path names a registered file is answered with it, and every other request reaches the application. A conditional request whose If-None-Match names the file's tag is answered 304 without the body. This is a middleware rather than a route so it composes with the assembled chain exactly as the reference implementation's does: the file response still carries the CORS, trace and access-log layers.