pub struct LiveReloadLayer<ReqPred = Always, ResPred = ContentTypeStartsWith<&'static str>> { /* private fields */ }Expand description
Layer to apply LiveReload middleware.
Implementations§
Source§impl LiveReloadLayer
impl LiveReloadLayer
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new LiveReloadLayer with default settings.
Source§impl<ReqPred, ResPred> LiveReloadLayer<ReqPred, ResPred>
impl<ReqPred, ResPred> LiveReloadLayer<ReqPred, ResPred>
Sourcepub fn custom_prefix<P: Into<String>>(self, prefix: P) -> Self
pub fn custom_prefix<P: Into<String>>(self, prefix: P) -> Self
Set a custom prefix for internal routes of the given
LiveReloadLayer.
Note that the provided prefix is not normalized before comparison. As such, it has to include a leading slash to match URL paths correctly.
Sourcepub fn request_predicate<Body, P: Predicate<Request<Body>>>(
self,
predicate: P,
) -> LiveReloadLayer<P, ResPred>
pub fn request_predicate<Body, P: Predicate<Request<Body>>>( self, predicate: P, ) -> LiveReloadLayer<P, ResPred>
Set a custom predicate for requests that should have their response HTML injected with live-reload logic.
Note that this predicate is applied in addition to the default response predicate, which makes sure that only HTML responses are injected.
Also see predicate for pre-defined predicates and
predicate::Predicate for how to implement your own predicates.
Sourcepub fn response_predicate<Body, P: Predicate<Response<Body>>>(
self,
predicate: P,
) -> LiveReloadLayer<ReqPred, P>
pub fn response_predicate<Body, P: Predicate<Response<Body>>>( self, predicate: P, ) -> LiveReloadLayer<ReqPred, P>
Set a custom predicate for responses that should be injected with live-reload logic.
Note that this predicate is applied instead of the default response
predicate, which would make sure that only HTML responses are injected.
However, even with a custom predicate only responses without a custom
encoding i.e. no Content-Encoding header can and will be injected.
Also see predicate for pre-defined predicates and
predicate::Predicate for how to implement your own predicates.
Sourcepub fn reload_interval(self, interval: Duration) -> Self
pub fn reload_interval(self, interval: Duration) -> Self
Set a custom retry interval for the live-reload logic.
Sourcepub fn reloader(&self) -> Reloader
pub fn reloader(&self) -> Reloader
Return a manual Reloader trigger for the given LiveReloadLayer.
Trait Implementations§
Source§impl<ReqPred: Clone, ResPred: Clone> Clone for LiveReloadLayer<ReqPred, ResPred>
impl<ReqPred: Clone, ResPred: Clone> Clone for LiveReloadLayer<ReqPred, ResPred>
Source§fn clone(&self) -> LiveReloadLayer<ReqPred, ResPred>
fn clone(&self) -> LiveReloadLayer<ReqPred, ResPred>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more