pub trait ResponseModifierPlugin: Send + Sync {
// Required methods
fn capabilities(&self) -> PluginCapabilities;
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn should_modify<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 ResponseRequest,
response: &'life3 ResponseData,
config: &'life4 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<bool>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait;
fn modify_response<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 ResponseRequest,
response: ResponseData,
config: &'life3 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<ResponseData>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
fn priority(&self) -> i32;
fn validate_config(&self, config: &ResponseModifierConfig) -> Result<()>;
fn cleanup<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Response modifier plugin trait
Implement this trait to modify responses after they have been generated. This allows plugins to transform, enhance, or filter responses before they are sent to the client.
Use cases include:
- Adding custom headers or metadata
- Compressing response bodies
- Encrypting sensitive data
- Filtering or redacting content
- Adding CORS headers
- Response validation
Required Methods§
Sourcefn capabilities(&self) -> PluginCapabilities
fn capabilities(&self) -> PluginCapabilities
Get plugin capabilities (permissions and limits)
Sourcefn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn initialize<'life0, 'life1, 'async_trait>(
&'life0 self,
config: &'life1 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Initialize the plugin with configuration
Sourcefn should_modify<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 ResponseRequest,
response: &'life3 ResponseData,
config: &'life4 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<bool>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
fn should_modify<'life0, 'life1, 'life2, 'life3, 'life4, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 ResponseRequest,
response: &'life3 ResponseData,
config: &'life4 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<bool>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
'life4: 'async_trait,
Sourcefn modify_response<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 ResponseRequest,
response: ResponseData,
config: &'life3 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<ResponseData>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn modify_response<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
context: &'life1 PluginContext,
request: &'life2 ResponseRequest,
response: ResponseData,
config: &'life3 ResponseModifierConfig,
) -> Pin<Box<dyn Future<Output = Result<PluginResult<ResponseData>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Modify the response
This method is called when the plugin has indicated it should modify the response. It receives the current response and returns a modified version.
§Arguments
context
- Plugin execution contextrequest
- Original request informationresponse
- Current response data to modifyconfig
- Plugin configuration
§Returns
Modified response data
Sourcefn priority(&self) -> i32
fn priority(&self) -> i32
Get plugin priority (lower numbers = higher priority, executed first)
Sourcefn validate_config(&self, config: &ResponseModifierConfig) -> Result<()>
fn validate_config(&self, config: &ResponseModifierConfig) -> Result<()>
Validate plugin configuration