static_web_server/static_files/
opts.rs1use headers::{HeaderMap, HeaderValue};
9use hyper::{Method, Response};
10use std::path::PathBuf;
11
12use crate::body::Body;
13
14#[cfg(feature = "mem-cache")]
15use crate::mem_cache::cache::MemCacheOpts;
16
17#[cfg(feature = "directory-listing")]
18use crate::directory_listing::DirListFmt;
19
20#[cfg(feature = "directory-listing-download")]
21use crate::directory_listing::download::DirDownloadFmt;
22
23pub(super) const DEFAULT_INDEX_FILES: &[&str; 1] = &["index.html"];
25
26pub struct HandleOpts<'a> {
28 pub method: &'a Method,
30 #[cfg(feature = "mem-cache")]
32 pub memory_cache: Option<&'a MemCacheOpts>,
33 pub headers: &'a HeaderMap<HeaderValue>,
35 pub base_path: &'a PathBuf,
37 pub uri_path: &'a str,
39 pub index_files: &'a [&'a str],
41 pub uri_query: Option<&'a str>,
43 #[cfg(feature = "directory-listing")]
45 #[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
46 pub dir_listing: bool,
47 #[cfg(feature = "directory-listing")]
49 #[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
50 pub dir_listing_order: u8,
51 #[cfg(feature = "directory-listing")]
53 #[cfg_attr(docsrs, doc(cfg(feature = "directory-listing")))]
54 pub dir_listing_format: &'a DirListFmt,
55 #[cfg(feature = "directory-listing-download")]
57 #[cfg_attr(docsrs, doc(cfg(feature = "directory-listing-download")))]
58 pub dir_listing_download: &'a [DirDownloadFmt],
59 pub redirect_trailing_slash: bool,
61 pub compression_static: bool,
63 pub etag: bool,
65 pub include_hidden: bool,
67 pub follow_symlinks: bool,
69}
70
71pub struct StaticFileResponse {
73 pub resp: Response<Body>,
75 pub file_path: PathBuf,
77}
78
79impl StaticFileResponse {
80 pub(super) fn new(resp: Response<Body>, file_path: PathBuf) -> Self {
82 Self { resp, file_path }
83 }
84}