pub struct Assets { /* private fields */ }Expand description
A folder served under a mount path.
use web_net::{App, Assets};
let app = App::builder()
.assets(Assets::new("/static", "./public").cache_control("public, max-age=31536000, immutable"))
.build()?;Implementations§
Source§impl Assets
impl Assets
Sourcepub fn new(mount: &str, dir: impl Into<PathBuf>) -> Self
pub fn new(mount: &str, dir: impl Into<PathBuf>) -> Self
Serves dir under mount (/static). The folder must exist when the
application is built.
Sourcepub fn cache_control(self, value: &str) -> Self
pub fn cache_control(self, value: &str) -> Self
The Cache-Control value (default no-cache: the browser keeps the
file and revalidates it, which a matching ETag answers with 304).
For files whose names change with their content:
public, max-age=31536000, immutable.
Sourcepub fn index(self, name: &str) -> Self
pub fn index(self, name: &str) -> Self
The file served for a folder (index.html). Without one, a folder
is a 404: there are never listings.
Sourcepub fn precompressed(self, on: bool) -> Self
pub fn precompressed(self, on: bool) -> Self
Whether file.br and file.gz next to a file are served to clients
that accept them (default on).
Serve names that start with a dot (default off: .env, .git,
.htaccess are 404).
Trait Implementations§
Auto Trait Implementations§
impl Forget for Assets
impl Freeze for Assets
impl RefUnwindSafe for Assets
impl Send for Assets
impl Sync for Assets
impl Unpin for Assets
impl UnsafeUnpin for Assets
impl UnwindSafe for Assets
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more