rocket::fs::rewrite

Trait Rewriter

Source
pub trait Rewriter:
    Send
    + Sync
    + 'static {
    // Required method
    fn rewrite<'r>(
        &self,
        opt: Option<Rewrite<'r>>,
        req: &'r Request<'_>,
    ) -> Option<Rewrite<'r>>;
}
Expand description

A file server Rewrite rewriter.

A FileServer is a sequence of Rewriters which transform the incoming request path into a Rewrite or None. The first rewriter is called with the request path as a Rewrite::File. Each Rewriter thereafter is called in-turn with the previously returned Rewrite, and the value returned from the last Rewriter is used to respond to the request. If the final rewrite is None or a nonexistent path or a directory, FileServer responds with Status::NotFound. Otherwise it responds with the file contents, if Rewrite::File is specified, or a redirect, if Rewrite::Redirect is specified.

Required Methods§

Source

fn rewrite<'r>( &self, opt: Option<Rewrite<'r>>, req: &'r Request<'_>, ) -> Option<Rewrite<'r>>

Alter the Rewrite as needed.

Implementations on Foreign Types§

Source§

impl Rewriter for PathBuf

Source§

fn rewrite<'r>( &self, _: Option<Rewrite<'r>>, _: &Request<'_>, ) -> Option<Rewrite<'r>>

Implementors§

Source§

impl Rewriter for Rewrite<'static>

Source§

impl Rewriter for Redirect

Source§

impl Rewriter for DirIndex

Source§

impl Rewriter for File<'static>

Source§

impl Rewriter for Prefix

Source§

impl Rewriter for TrailingDirs

Source§

impl<F> Rewriter for F
where F: for<'r> Fn(Option<Rewrite<'r>>, &Request<'_>) -> Option<Rewrite<'r>> + Send + Sync + 'static,