pub struct RedirectPlugin {
http_to_https: bool,
uri: Option<String>,
ret_code: u16,
append_query_string: bool,
}Expand description
Builds a redirect response from either a uri template (with $var
interpolation) or the http_to_https shortcut.
This plugin never fails at execution time. The only case where it does
not redirect is http_to_https on a request that is already HTTPS
(per x-forwarded-proto or the request scheme): the context passes
through unchanged, so http_to_https should only be wired into routes
served over plain HTTP.
Fields§
§http_to_https: boolRedirect plain-HTTP requests to https://$host$request_uri.
uri: Option<String>Redirect target template; $var / ${var} are interpolated.
ret_code: u16Status code for uri redirects (http_to_https picks 301/308 itself).
append_query_string: boolAppend the original query string to the target.
Implementations§
Source§impl RedirectPlugin
impl RedirectPlugin
Sourcepub fn from_config(config: &HashMap<String, Value>) -> Result<Self, String>
pub fn from_config(config: &HashMap<String, Value>) -> Result<Self, String>
Builds the plugin from node config.
Accepted keys — exactly one of uri / http_to_https: true is
required:
uri(string): redirect target template.$varand${var}references are interpolated against the context (seecrate::vars::interpolate), e.g./new$request_uriorhttps://$host/login. Unknown variables resolve to"".http_to_https(bool): redirect HTTP requests tohttps://$host$request_uriwith301for GET/HEAD and308otherwise (so the method and body survive). Already-HTTPS requests pass through unchanged.ret_code(integer, default302, minimum200): status code foruriredirects.append_query_string(bool, defaultfalse): append the original query string to the target (?or&as appropriate). Cannot be combined withhttp_to_https, which already keeps the query string via$request_uri.
type: redirect
config:
uri: https://$host/new-prefix$uri
ret_code: 301
append_query_string: trueTrait Implementations§
Source§impl Plugin for RedirectPlugin
impl Plugin for RedirectPlugin
Source§fn plugin_type(&self) -> &str
fn plugin_type(&self) -> &str
Unique identifier for the plugin type (e.g., “proxy-rewrite”, “upstream”).
Source§fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context,
_named_inputs: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn execute<'life0, 'life1, 'async_trait>(
&'life0 self,
ctx: Context,
_named_inputs: &'life1 HashMap<String, Value>,
) -> Pin<Box<dyn Future<Output = Result<PluginOutput, PluginExecutionError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Executes the plugin logic against the request/response context. Read more
Auto Trait Implementations§
impl Freeze for RedirectPlugin
impl RefUnwindSafe for RedirectPlugin
impl Send for RedirectPlugin
impl Sync for RedirectPlugin
impl Unpin for RedirectPlugin
impl UnsafeUnpin for RedirectPlugin
impl UnwindSafe for RedirectPlugin
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more