Git Product home page Git Product logo

java-plugin-runner-demo-1's Introduction

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

java-plugin-runner-demo-1's People

Contributors

tzssangglass avatar ericluoliu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.