TrustGate allows developers to create their own plugins to extend the functionality of the gateway. Custom plugins run natively inside the gateway process and have full access to request and response contexts, making them ideal for advanced security checks, transformations, logging, or custom business logic.
All custom plugins should be added to the folder:
Each plugin should reside in its own subfolder within pkg/plugins
, and be registered during initialization using the plugin manager.
To be recognized by TrustGate, every plugin must implement the following interface:
Plugins can run at any of the following stages:
pre_request
post_request
pre_response
post_response
You can restrict a plugin to run only at specific stages by implementing the Stages()
method, or validate supported stages using the AllowedStages()
method.
To make your plugin available to TrustGate, you must register it inside the plugin manager.
All plugin registrations happen in the Manager
’s initializePlugins()
method, located in:
Within that file, locate the following function:
Each plugin can be configured declaratively through the gateway configuration, a specific rule, or a consumer group. Below is an example of a plugin configuration block:
name: The name of the plugin, as returned by its Name()
method.
enabled: Whether the plugin should be active.
stage: The execution stage (pre_request
, post_request
, etc.).
priority: Used when multiple plugins run sequentially; lower numbers run first.
settings: Custom key-value pairs passed into the plugin for configuration and validation.
Always validate configuration using ValidateConfig()
to avoid runtime errors.
Use PluginResponse
to control execution flow (continue
, reject
, halt
, etc.).
Plugins should be deterministic and fast — avoid long-running logic in the execution path.
Consider writing unit tests for plugin logic in isolation.
Avoid leaking sensitive data in logs unless explicitly masked or filtered.
TrustGate allows developers to create their own plugins to extend the functionality of the gateway. Custom plugins run natively inside the gateway process and have full access to request and response contexts, making them ideal for advanced security checks, transformations, logging, or custom business logic.
All custom plugins should be added to the folder:
Each plugin should reside in its own subfolder within pkg/plugins
, and be registered during initialization using the plugin manager.
To be recognized by TrustGate, every plugin must implement the following interface:
Plugins can run at any of the following stages:
pre_request
post_request
pre_response
post_response
You can restrict a plugin to run only at specific stages by implementing the Stages()
method, or validate supported stages using the AllowedStages()
method.
To make your plugin available to TrustGate, you must register it inside the plugin manager.
All plugin registrations happen in the Manager
’s initializePlugins()
method, located in:
Within that file, locate the following function:
Each plugin can be configured declaratively through the gateway configuration, a specific rule, or a consumer group. Below is an example of a plugin configuration block:
name: The name of the plugin, as returned by its Name()
method.
enabled: Whether the plugin should be active.
stage: The execution stage (pre_request
, post_request
, etc.).
priority: Used when multiple plugins run sequentially; lower numbers run first.
settings: Custom key-value pairs passed into the plugin for configuration and validation.
Always validate configuration using ValidateConfig()
to avoid runtime errors.
Use PluginResponse
to control execution flow (continue
, reject
, halt
, etc.).
Plugins should be deterministic and fast — avoid long-running logic in the execution path.
Consider writing unit tests for plugin logic in isolation.
Avoid leaking sensitive data in logs unless explicitly masked or filtered.