Struct saphir::file::middleware::FileMiddlewareBuilder
source · pub struct FileMiddlewareBuilder { /* private fields */ }
file
only.Implementations§
source§impl FileMiddlewareBuilder
impl FileMiddlewareBuilder
pub fn new(base_path: &str, www_path: &str) -> Self
sourcepub fn max_file_size(self, size: u64) -> Self
pub fn max_file_size(self, size: u64) -> Self
Maximum size of a single file for the in-memory cache. Files exceeding this size won’t be cached, regardless of the specified cache max capacity.
Default: 2MB
sourcepub fn max_capacity(self, size: u64) -> Self
pub fn max_capacity(self, size: u64) -> Self
Maximum total capacity for the in-memory cache. All fetched files will be kept cached in memory until reaching this maximum capacity.
Default: 512MB
sourcepub fn max_age(self, max_age: i64) -> Self
pub fn max_age(self, max_age: i64) -> Self
Specify the Cache-Control: max-age
header returned by this middleware.
Default: Cache-Control: max-age=0
sourcepub fn index_files(self, index_files: &str) -> Self
pub fn index_files(self, index_files: &str) -> Self
Specify a list of index files which will be tried in order when reaching a directory. This behave similarly to nginx’s index directive.
Default: "index.html index.htm"
.
sourcepub fn no_directory_index(self) -> Self
pub fn no_directory_index(self) -> Self
Specify that no index file should be looked up when pointing to a
directory. This effectively remove the default index.html
and
index.htm
index files.
sourcepub fn try_files(self, try_files: &str) -> Self
pub fn try_files(self, try_files: &str) -> Self
List of files to try. This should be construced using the $uri
token.
This behave similarly to nginx’s try_files directive.
Default: "$uri $uri"
.
sourcepub fn file_not_found_handler<H>(self, handler: H) -> Selfwhere
H: 'static + DynHandler<Body> + Sync + Send,
pub fn file_not_found_handler<H>(self, handler: H) -> Selfwhere H: 'static + DynHandler<Body> + Sync + Send,
Attach a handler to be called when the requested file is not found.