You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2021/07/31 12:55:57 UTC

[GitHub] [apisix-java-plugin-runner] tzssangglass edited a comment on issue #54: request help: 写的测试插件不起作用

tzssangglass edited a comment on issue #54:
URL: https://github.com/apache/apisix-java-plugin-runner/issues/54#issuecomment-890343673


   > request.setArg("test_arg", "test_value");
   > 
   > response.setHeader("para_test", "test");
   
   `request.setArg("test_arg", "test_value");` means that rewrite the current request, take a look at: https://github.com/apache/apisix-java-plugin-runner/blob/main/docs/en/latest/development.md#rewrite-request
   
   `response.setHeader("para_test", "test");` means that stop the current request, the client will receive the relevant parameters generated here. take a look at: https://github.com/apache/apisix-java-plugin-runner/blob/main/docs/en/latest/development.md#stop-request
   
   **If both of these exist, then the request will be stopped.** 
   
   the `config.yaml` of apisix:
   
   ```
   ext-plugin:
     cmd: ['java', '-jar', '-Xmx4g', '-Xms4g', '/root/IdeaProjects/apisix-java-plugin-runner/runner-dist/apisix-runner-bin-dist/target/apisix-runner-bin/apisix-runner-bin/apisix-java-plugin-runner.jar']
   ```
   
   log of successful jar startup output in apisix's `error.log`:
   
   ```
   2021/07/31 20:53:07 [warn] 107773#107773: *69 [lua] init.lua:620: 
     .   ____          _            __ _ _
    /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
   ( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
    \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
     '  |____| .__|_| |_|_| |_\__, | / / / /
   , context: ngx.timer
   2021/07/31 20:53:07 [warn] 107773#107773: *69 [lua] init.lua:620:  =========|_|==============|___/=/_/_/_/
   , context: ngx.timer
   2021/07/31 20:53:07 [warn] 107773#107773: *69 [lua] init.lua:620:  :: Spring Boot ::                (v2.4.5), context: ngx.timer
   2021/07/31 20:53:07 [warn] 107773#107773: *69 [lua] init.lua:620: 
   , context: ngx.timer
   2021/07/31 20:53:07 [warn] 107773#107773: *69 [lua] init.lua:620: 
   , context: ngx.timer
   2021/07/31 20:53:07 [warn] 107773#107773: *69 [lua] init.lua:620: 2021-07-31 20:53:07.993  INFO 107784 --- [           main] o.a.a.p.r.PluginRunnerApplication        : Starting PluginRunnerApplication v0.1.0 using Java 11.0.11 on localhost.localdomain with PID 107784 (/root/IdeaProjects/apisix-java-plugin-runner/runner-dist/apisix-runner-bin-dist/target/apisix-runner-bin/apisix-runner-bin/apisix-java-plugin-runner.jar started by root in /usr/local/apisix)
   , context: ngx.timer
   2021/07/31 20:53:07 [warn] 107773#107773: *69 [lua] init.lua:620: 2021-07-31 20:53:07.996  INFO 107784 --- [           main] o.a.a.p.r.PluginRunnerApplication        : No active profile set, falling back to default profiles: default
   , context: ngx.timer
   2021/07/31 20:53:09 [warn] 107773#107773: *69 [lua] init.lua:620: 2021-07-31 20:53:09.618  INFO 107784 --- [           main] o.a.a.p.r.PluginRunnerApplication        : Started PluginRunnerApplication in 2.004 seconds (JVM running for 2.605)
   , context: ngx.timer
   2021/07/31 20:53:09 [warn] 107773#107773: *69 [lua] init.lua:620: 2021-07-31 20:53:09.793  WARN 107784 --- [           main] o.a.a.p.r.s.ApplicationRunner            : java runner is listening on the socket file: /usr/local/apisix/conf/apisix-107767.sock
   , context: ngx.timer
   
   ``` 
   
   Using the same environment and code as yours, here are my reproduction results:
   
   ```
   $ curl -i 127.0.0.1:9080/get 
   HTTP/1.1 500 Internal Server Error
   Date: Sat, 31 Jul 2021 12:40:19 GMT
   Content-Type: text/html; charset=utf-8
   Content-Length: 553
   Connection: close
   para-test: test
   ETag: "610544ac-229"
   Server: APISIX/2.7
   ```
   
   the `para-test` header has been successfully returned to the client.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org