Skip to content
Browse files
docs: adding function definitions for the PluginFilter interface (#108)
  • Loading branch information
tzssangglass committed Jan 4, 2022
1 parent 3da21b9 commit 6197a8e5196b25bf556eaf8a7d2eb7a25053ab57
Showing 3 changed files with 75 additions and 1 deletion.
@@ -20,9 +20,15 @@ security, traffic control, serverless, analytics & monitoring, transformations,
It also provides highly extensible API, allowing common phases to be mounted,
and users can use these api to develop their own plugins.

APISIX supports writing plugins in multiple languages in version [2.7.0](,
this project is APISIX Java side implementation that supports writing plugins in java.

Version Matrix

| apisix-java-plugin-runner | APISIX |
| 0.1.0 | >= [2.7.0]( |
| 0.2.0 | >= [2.10.2]( |

How it Works
@@ -87,6 +87,74 @@ curl -H 'X-API-KEY: edd1c9f034335f13
apisix-java-plugin-runner will look for implementation classes named `FooFilter`,
and the name of each filter's implementation class is the return value of its overridden function `public String name()`.

#### The functions must be implemented of filter execution

- `String name();`

description: return the name of plugin filter

code example:

public String name() {
return "FooFilter";

- `void filter(HttpRequest request, HttpResponse response, PluginFilterChain chain);`

description: implementing custom business logic

code example:

public void filter(HttpRequest request, HttpResponse response, PluginFilterChain chain) {
// get conf of current filter
String configStr = request.getConfig(this);
Gson gson = new Gson();
Map<String, Object> conf = new HashMap<>();
// convert according to the actual configured conf type
conf = gson.fromJson(configStr, conf.getClass());
// get extra info
String remoteAddr = request.getVars("remote_addr");
String serverPort = request.getVars("server_port");
String body = request.getBody();
chain.filter(request, response);

- `List<String> requiredVars();`

description: declare in advance the nginx variables you want to use in the current filter

code example:

public List<String> requiredVars() {
List<String> vars = new ArrayList<>();
return vars;

- `Boolean requiredBody();`

description: whether the request body is required in the current filter, true means yes.

code example:

public Boolean requiredBody() {
return true;

#### Rewrite Request

File renamed without changes.

0 comments on commit 6197a8e

Please sign in to comment.