pub trait StaticFileConfig {
type FileService: FileServeConfig + 'static;
type DirService: DirectoryListingConfig;
// Provided methods
fn is_method_allowed(method: &Method) -> bool { ... }
fn serve_dir(&self) -> &Path { ... }
fn router_prefix(&self) -> &str { ... }
fn index_file(&self, _path: &Path) -> Option<&Path> { ... }
fn handle_directory(&self, _path: &Path) -> bool { ... }
fn handle_not_found(
&self,
_path: &Path,
_out_headers: &mut HeaderMap,
) -> (StatusCode, Bytes) { ... }
fn on_request(&self, _method: &Method, _uri: &Uri, _headers: &HeaderMap) { ... }
fn on_response(&self, _parts: &mut Parts) { ... }
}Expand description
Configuration description
Required Associated Types§
Sourcetype FileService: FileServeConfig + 'static
type FileService: FileServeConfig + 'static
File serve configuration
Sourcetype DirService: DirectoryListingConfig
type DirService: DirectoryListingConfig
Directory serve configuration
Provided Methods§
Sourcefn is_method_allowed(method: &Method) -> bool
fn is_method_allowed(method: &Method) -> bool
Returns whether specified method is allowed for use.
By default allows HEAD and GET
Sourcefn router_prefix(&self) -> &str
fn router_prefix(&self) -> &str
Specifies router prefix.
To be used by frameworks such as Actix
Defaults to /
Sourcefn index_file(&self, _path: &Path) -> Option<&Path>
fn index_file(&self, _path: &Path) -> Option<&Path>
Returns name of index file to show.
path points to directory relative to StaticFileConfig::serve_dir.
By default returns None
Sourcefn handle_directory(&self, _path: &Path) -> bool
fn handle_directory(&self, _path: &Path) -> bool
Returns whether directory should be listed on access
path points to directory relative to StaticFileConfig::serve_dir.
By default returns false
Sourcefn handle_not_found(
&self,
_path: &Path,
_out_headers: &mut HeaderMap,
) -> (StatusCode, Bytes)
fn handle_not_found( &self, _path: &Path, _out_headers: &mut HeaderMap, ) -> (StatusCode, Bytes)
Handles entry that hasn’t been found.
path points to entry relative to StaticFileConfig::serve_dir.
By default prepares empty NotFound response with empty body
Sourcefn on_request(&self, _method: &Method, _uri: &Uri, _headers: &HeaderMap)
fn on_request(&self, _method: &Method, _uri: &Uri, _headers: &HeaderMap)
Callback to be called when request is received
By default does nothing
Sourcefn on_response(&self, _parts: &mut Parts)
fn on_response(&self, _parts: &mut Parts)
Callback to be called before response is sent to the client
By default does nothing
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.