pub struct EchoPlugin {
body: Option<String>,
before_body: Option<String>,
after_body: Option<String>,
headers: HashMap<String, String>,
}Expand description
Rewrites the response: body replaces the upstream body, then
before_body / after_body are concatenated around it, and headers
are set on the response (replacing any existing values, like
ngx.header[...]).
Because the body is mutated, the plugin follows featherbit’s body-mutation
convention: content-length is removed (the server recomputes it) and a
compressed upstream body is decoded first, with content-encoding
removed. This plugin never fails at execution time.
Fields§
§body: Option<String>Replacement for the upstream response body.
before_body: Option<String>Prepended to the (possibly replaced) body.
after_body: Option<String>Appended to the (possibly replaced) body.
headers: HashMap<String, String>Response headers to set (names lowercased, values replace existing).
Implementations§
Source§impl EchoPlugin
impl EchoPlugin
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 — at least one of body / before_body / after_body
is required (APISIX parity):
body(string): replaces the upstream response body.before_body(string): prepended to the body (after anybodyreplacement).after_body(string): appended to the body.headers(map{name: value}or array[{name, value}], the UI editor’s form): response headers to set. Values must be scalars (strings, numbers, bools — stringified); names are lowercased; array entries with a blanknameare skipped. Existing values for the same header are replaced.
type: echo
config:
before_body: "before the body modification "
after_body: " after the body modification"
headers:
x-served-by: featherbitTrait Implementations§
Source§impl Plugin for EchoPlugin
impl Plugin for EchoPlugin
Source§fn plugin_type(&self) -> &str
fn plugin_type(&self) -> &str
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,
Auto Trait Implementations§
impl Freeze for EchoPlugin
impl RefUnwindSafe for EchoPlugin
impl Send for EchoPlugin
impl Sync for EchoPlugin
impl Unpin for EchoPlugin
impl UnsafeUnpin for EchoPlugin
impl UnwindSafe for EchoPlugin
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
§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>
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>
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