pub struct ProxyRewritePlugin {
strip_path_prefix: Option<String>,
add_path_prefix: Option<String>,
add_headers: HashMap<String, String>,
remove_headers: Vec<String>,
phase: RewritePhase,
}Expand description
Mutates either Context.request or Context.response (selected by
phase): strips/adds a path prefix and adds/removes headers. Path
rewriting only applies in the request phase; header names are lowercased
before being applied. This plugin never fails at execution time.
Fields§
§strip_path_prefix: Option<String>§add_path_prefix: Option<String>§add_headers: HashMap<String, String>§remove_headers: Vec<String>§phase: RewritePhaseImplementations§
Source§impl ProxyRewritePlugin
impl ProxyRewritePlugin
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 (all optional):
phase(string, defaultrequest):requestorresponse; any value other thanresponsefalls back torequest.strip_path_prefix(string): prefix removed from the request path when it matches; the result is normalized to start with/.add_path_prefix(string): prefix prepended to the request path (after stripping).add_headers(map{name: value}or array[{name, value}], the UI editor’s form): headers to append. Scalar values are stringified; malformed shapes (e.g. a plain string, or nested objects as values) error here at config load.remove_headers(array of strings): header names to delete.
type: proxy-rewrite
config:
phase: request
strip_path_prefix: /api/v1
add_headers:
x-forwarded-tier: edge
remove_headers: [x-internal]Trait Implementations§
Source§impl Plugin for ProxyRewritePlugin
impl Plugin for ProxyRewritePlugin
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 ProxyRewritePlugin
impl RefUnwindSafe for ProxyRewritePlugin
impl Send for ProxyRewritePlugin
impl Sync for ProxyRewritePlugin
impl Unpin for ProxyRewritePlugin
impl UnsafeUnpin for ProxyRewritePlugin
impl UnwindSafe for ProxyRewritePlugin
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