Trait rocket::fs::rewrite::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,