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.Documentation Index
Fetch the complete documentation index at: https://docs.neuraltrust.ai/llms.txt
Use this file to discover all available pages before exploring further.
Plugin Location
All custom plugins should be added to the folder:pkg/plugins, and be registered during initialization using the plugin manager.
Plugin Interface
To be recognized by TrustGate, every plugin must implement the following interface:Stage Lifecycle
Plugins can run at any of the following stages:pre_requestpost_requestpre_responsepost_response
Stages() method, or validate supported stages using the AllowedStages() method.
Plugin Registration
To make your plugin available to TrustGate, you must register it inside the plugin manager. All plugin registrations happen in theManager’s initializePlugins() method, located in:
Plugin Configuration
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.
Example Plugin Skeleton
Tips for Writing Plugins
-
Always validate configuration using
ValidateConfig()to avoid runtime errors. -
Use
PluginResponseto 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.