ScriptableFilter
Processes requests and responses by using a Groovy script.
When a ScriptableFilter processes a request, it can execute
return next.handle(context, request)
to call the next filter or handler in the
current chain and return the value from the call. Actions on the response must
be performed in the Promise’s callback methods.
Scripts must return a Promise<Response, NeverThrowsException> or a Response.
This section describes the usage of ScriptableFilter, and refers to the following sections of the documentation:
-
For information about script properties, available global objects, and automatically imported classes, see Scripts.
-
For information about creating scriptable objects in Studio, see Scripts in Studio and Configure scriptable throttling.
Usage
{
"name": string,
"type": "ScriptableFilter",
"config": {
"type": configuration expression<string>,
"file": configuration expression<string>, // Use either "file"
"source": [ string, ... ], // or "source", but not both.
"args": map,
"clientHandler": Handler reference
}
}
Properties
For information about properties for ScriptableFilter, see Scripts.
Examples
For an example scriptable filter that recovers policy advices from AM,
see the failureHandler
property of
PolicyEnforcementFilter.