Rust

files

Module

Static files loaded into memory and served by crate::Http::run for an exact URI match.

Contents

use utopia_http::File;
Rust
pub struct File

A loaded file: its contents and MIME type.

use utopia_http::Files;
Rust
pub struct Files

Files loaded from directories, by URI (the path relative to the load root, starting with /).

use utopia_http::files::sniff;
Rust
pub fn sniff(contents: &[u8]) -> &'static str

Guesses the MIME type of file contents: signatures of common binary formats (PNG, GIF, JPEG, WebP, PDF, ZIP, gzip), HTML, JSON and text, else application/octet-stream.

Rust
pub const EXTENSIONS: [(&str, &str); 3] = [("css", "text/css"), ("js", "text/javascript"), ("svg", "image/svg+xml")]

MIME types by extension that override content sniffing: CSS, JavaScript and SVG.