Skip to main content

domi_server/serve/file/
mod.rs

1//! Static file serving pipeline.
2//!
3//! - [`safety`] — path classification, content-type mapping, escape checks
4//! - [`static_get`] — body shaping (HTML shim injection) and the
5//!   `serve_file` read path
6//!
7//! Public surface preserved at `crate::serve::file::*`.
8
9pub mod safety;
10pub mod static_get;
11
12#[cfg(test)]
13mod tests;
14
15pub use static_get::serve_file;
16
17use std::io;
18
19/// Response body returned by `serve_file`.
20#[derive(Debug)]
21pub struct ServedFile {
22    pub body: Vec<u8>,
23    pub content_type: ContentType,
24}
25
26#[derive(Debug, Clone, Copy, PartialEq, Eq)]
27pub enum ContentType {
28    Html,
29    Css,
30    Js,
31    Json,
32    Png,
33    Jpeg,
34    Svg,
35    PlainText,
36    OctetStream,
37}
38
39#[derive(Debug)]
40#[non_exhaustive]
41pub enum ServeError {
42    NotFound,
43    NotAFile,
44    Io(io::Error),
45    EscapedRoot,
46}