Skip to content

tzssangglass/java-plugin-runner-demo-1

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

User Guide

  1. build jar file
./mvnw clean package

and the jar file will be generated in target folder, like demo-0.0.1-SNAPSHOT.jar.

  1. confif the ext-plugin in config.yaml of APISIX
ext-plugin:
  cmd: ['java', '-jar', '-Xmx1g', '-Xms1g', '/path/to/demo-0.0.1-SNAPSHOT.jar'] # d

NOTE: replace /path/to/demo-0.0.1-SNAPSHOT.jar to the real path of the jar file in your environment.

  1. start APISIX, and add route with ext-plugin-pre-req plugin
curl -i http://127.0.0.1:9180/apisix/admin/routes/1  -H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' -X PUT -d '
{
    "uri": "/get",
    "plugins": {
        "ext-plugin-pre-req": {
            "conf" : [
                {"name": "DemoFilter", "value": "{\"enable\":\"feature\"}"}
            ]
        }
    },
    "upstream": {
        "type": "roundrobin",
        "nodes": {
            "httpbin.org:80": 1
        }
    }
}'
  1. test the route
curl http://127.0.0.1:9080/get
{
  "args": {},
  "headers": {
    "Accept": "*/*",
    "Host": "127.0.0.1",
    "User-Agent": "curl/7.79.1",
    "X-Amzn-Trace-Id": "Root=1-634ec286-02980c910f0608973ea7d9df",
    "X-Forwarded-Host": "127.0.0.1"
  },
  "origin": "127.0.0.1, 103.152.220.40",
  "url": "http://127.0.0.1/get"
}

check the error log of APISIX, you will see the log like this:

2022/10/18 23:13:09 [warn] 95270#82969626: *369 [lua] init.lua:955: 2022-10-18 23:13:09.828  WARN 95295 --- [ntLoopGroup-2-2] c.e.d.DemoFilter                         : DemoFilter is running
, context: ngx.timer

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 100.0%