pub enum TrailingSlash {
Redirect,
Serve,
}Expand description
How a directory request that omits its trailing slash is answered, set via
crate::Server::with_trailing_slash.
A directory is served through its index.html, and the URL that names that
directory canonically ends in /. The two variants differ in what happens when a
request arrives without one.
Variants§
Redirect
Answer with 301 to the slashed URL. The default, and the right behaviour for
any site whose pages carry relative links or relative asset paths: a browser
resolves those against the last / in the address, so a page served at
/guide/setup would resolve img.png to /guide/img.png — the parent
directory — while the same page served at /guide/setup/ resolves it to
/guide/setup/img.png, where it actually lives.
Serve
Serve the page directly, with 200, at the unslashed URL too.
Costs a round-trip less than the redirect, at the price of one page answering to
two addresses. Only correct for a site whose every link and asset path is
root-absolute (/styles.css, never styles.css or ./styles.css) — see
Self::Redirect for what a relative path does at the unslashed URL. Nothing
here can detect the difference, so this is an assertion the caller makes about
their own markup.
Trait Implementations§
Source§impl Clone for TrailingSlash
impl Clone for TrailingSlash
Source§fn clone(&self) -> TrailingSlash
fn clone(&self) -> TrailingSlash
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for TrailingSlash
Source§impl Debug for TrailingSlash
impl Debug for TrailingSlash
Source§impl Default for TrailingSlash
impl Default for TrailingSlash
Source§fn default() -> TrailingSlash
fn default() -> TrailingSlash
impl Eq for TrailingSlash
Source§impl PartialEq for TrailingSlash
impl PartialEq for TrailingSlash
impl StructuralPartialEq for TrailingSlash
Auto Trait Implementations§
impl Freeze for TrailingSlash
impl RefUnwindSafe for TrailingSlash
impl Send for TrailingSlash
impl Sync for TrailingSlash
impl Unpin for TrailingSlash
impl UnsafeUnpin for TrailingSlash
impl UnwindSafe for TrailingSlash
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.