Strata is pre-1.0. APIs, protocol, and storage format may change.
strata_server/static
Static file serving for the strata HTTP layer.
Resolves request paths against a directory on disk, returning a
mist ResponseData that streams the file contents. Implements a
tiny content-type table covering the file types our examples and
admin SPA need; everything else is application/octet-stream.
Path traversal protection: paths containing .. are rejected with
404. Absolute paths and paths with backslashes are normalised
before joining.
Functions
Section titled “Functions”try_serve
Section titled “try_serve”Serve a static asset from root_dir. Returns Some(response) when
the request maps to a regular file, None otherwise (so the caller
can fall through to the next handler — typically a 404 page).
pub fn try_serve( request.Request(a), String) -> option.Option(response.Response(mist.ResponseData))try_serve_spa
Section titled “try_serve_spa”Serve a mounted single-page app with fallback to index.html.
pub fn try_serve_spa( request.Request(a), String, mount_path: String) -> option.Option(response.Response(mist.ResponseData))