This is an automated email from the ASF dual-hosted git repository.

tzssangglass pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/apisix-java-plugin-runner.git


The following commit(s) were added to refs/heads/main by this push:
     new 6197a8e  docs: adding function definitions for the PluginFilter 
interface (#108)
6197a8e is described below

commit 6197a8e5196b25bf556eaf8a7d2eb7a25053ab57
Author: tzssangglass <[email protected]>
AuthorDate: Tue Jan 4 09:20:47 2022 +0800

    docs: adding function definitions for the PluginFilter interface (#108)
---
 README.md                                  |  8 +++-
 docs/en/latest/development.md              | 68 ++++++++++++++++++++++++++++++
 docs/zh/{Quick Start.md => quick-start.md} |  0
 3 files changed, 75 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index d68789c..c006b7d 100644
--- a/README.md
+++ b/README.md
@@ -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](https://github.com/apache/apisix/blob/master/CHANGELOG.md#270),
 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](https://github.com/apache/apisix/blob/master/CHANGELOG.md#270)   |
+| 0.2.0                     | >= 
[2.10.2](https://github.com/apache/apisix/blob/master/CHANGELOG.md#2102) |
 
 How it Works
 -------------
diff --git a/docs/en/latest/development.md b/docs/en/latest/development.md
index 1eeaa1a..db007a7 100644
--- a/docs/en/latest/development.md
+++ b/docs/en/latest/development.md
@@ -87,6 +87,74 @@ curl http://127.0.0.1:9080/apisix/admin/routes/1 -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:
+  
+  ```java
+    @Override
+    public String name() {
+        return "FooFilter";
+    }
+  ```
+
+- `void filter(HttpRequest request, HttpResponse response, PluginFilterChain 
chain);`
+
+  description: implementing custom business logic
+
+  code example:
+
+  ```java
+    @Override
+    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:
+
+  ```java
+    @Override
+    public List<String> requiredVars() {
+        List<String> vars = new ArrayList<>();
+        vars.add("remote_addr");
+        vars.add("server_port");
+        return vars;
+    }
+  ```
+
+- `Boolean requiredBody();`
+
+  description: whether the request body is required in the current filter, 
true means yes.
+
+  code example:
+
+  ```java
+    @Override
+    public Boolean requiredBody() {
+        return true;
+    }
+  ```
 
 ####  Rewrite Request
 
diff --git a/docs/zh/Quick Start.md b/docs/zh/quick-start.md
similarity index 100%
rename from docs/zh/Quick Start.md
rename to docs/zh/quick-start.md

Reply via email to