Expand description
The static file module which powers the web server.
The request pipeline is intentionally linear and reads top-to-bottom in
handle:
- Method check —
GET,HEADandOPTIONSonly. - Path sanitization — strip traversal components from the URI path.
- In-memory cache lookup — short-circuit hot files.
- File resolution — directory → index,
.htmlfallback, pre-compressed variant detection (see [resolve]). - Security checks — containment, symlink and hidden-file policy
(see [
security]). - Short-circuit responses — trailing-slash redirect,
OPTIONS, directory listing or archive download. - File reply — stream the resolved file or its pre-compressed
variant (see [
reply]).
Structs§
- Handle
Opts - Defines all options needed by the static-files handler.
- Static
File Response - Static file response type with additional data.
Functions§
- handle
- The server entry point to handle incoming requests which map to specific files on file system and return a file response.