pub struct RequestIdPlugin {
header_name: String,
include_in_response: bool,
}Expand description
Guarantees a request-id header on the request: when the header is absent
(or empty) a fresh UUID v4 is generated and set; an id supplied by the
client is kept as-is. With include_in_response the same id is also set
on the response, unless the response already carries one.
This plugin never fails at execution time.
Note on placement: the upstream node replaces context.response.headers
wholesale with the upstream’s response headers. To guarantee the id on the
response, place a second request-id node after upstream — it finds the
request header already set, reuses the same id, and stamps it on the
response.
Fields§
§header_name: StringLowercased name of the id header.
include_in_response: boolWhen true, the id is echoed on the response (if not already present).
Implementations§
Source§impl RequestIdPlugin
impl RequestIdPlugin
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):
header_name(string, defaultX-Request-Id): header carrying the id (lowercased internally, per featherbit’s header convention).include_in_response(bool, defaulttrue): also set the id on the response when the response does not already carry the header.algorithm(string, defaultuuid): id generation algorithm. Onlyuuid(UUID v4) is supported; any other value (APISIX also offersnanoid,range_id,ksuid,uuidv7) is a config error.
type: request-id
config:
header_name: X-Request-Id
include_in_response: true
algorithm: uuidTrait Implementations§
Source§impl Plugin for RequestIdPlugin
impl Plugin for RequestIdPlugin
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 RequestIdPlugin
impl RefUnwindSafe for RequestIdPlugin
impl Send for RequestIdPlugin
impl Sync for RequestIdPlugin
impl Unpin for RequestIdPlugin
impl UnsafeUnpin for RequestIdPlugin
impl UnwindSafe for RequestIdPlugin
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