Rdebu commented on issue #54: URL: https://github.com/apache/apisix-java-plugin-runner/issues/54#issuecomment-891615001
> > Is that a splice after apisix's IP + port ?If yes, if I want to jump to another IP port,what can I do? > > This cannot be done in java runner. I think you should configure upstream in apisix to do this. > > > there is a "request.setArg()" Is the ARG of a POST request in the body of the request > > no > > > Is the ARG of a GET request in the URI > > yes, see: https://github.com/openresty/lua-nginx-module#ngxreqset_uri_args The second question is: the path to the rewrite must start with '/' I have a need :I access 127.0.0.1:9080/* for all requests can forward to 127.0.0.1:9080/apisix/admin/routes but i failed  What's my problem? my route is : { "uris": [ "/*" ], "name": "TestFilter_route", "desc": "TestFilter_route", "methods": [ "GET", "POST", "PUT", "DELETE", "PATCH", "HEAD", "OPTIONS", "CONNECT", "TRACE" ], "hosts": [ "127.0.0.1" ], "remote_addrs": [ "127.0.0.1" ], "plugins": { "ext-plugin-pre-req": { "conf": [ { "name": "TestFilter", "value": "{\"rewrite_path\":\"/apisix/admin/routes\",\"conf_header_name\":\"X-API-KEY\",\"conf_header_value\":\"edd1c9f034335f136f87ad84b625c8f1\"}" } ] } }, "upstream_id": "366061654728770074", "labels": { "API_VERSION": "V1" }, "status": 1 } my TestFilter.java is /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.apisix.plugin.runner.filter; import com.google.gson.Gson; import lombok.extern.slf4j.Slf4j; import org.apache.apisix.plugin.runner.HttpRequest; import org.apache.apisix.plugin.runner.HttpResponse; import org.springframework.stereotype.Component; import reactor.core.publisher.Mono; import java.util.HashMap; import java.util.Map; @Component @Slf4j public class TestFilter implements PluginFilter { @Override public String name() { /* It is recommended to keep the name of the filter the same as the class name. Configure the filter to be executed on apisix's routes in the following format { "uri": "/hello", "plugins": { "ext-plugin-pre-req": { "conf": [{ "name": "TestFilter", "value": "bar" }] } }, "upstream": { "nodes": { "127.0.0.1:1980": 1 }, "type": "roundrobin" } } The value of name in the configuration corresponds to the value of return here. */ return "TestFilter"; } @Override public Mono<Void> filter(HttpRequest request, HttpResponse response, PluginFilterChain chain) { /* * If the conf you configured is of type json, you can convert it to Map or json. */ String configStr = request.getConfig(this); Gson gson = new Gson(); Map<String, Object> conf = new HashMap<>(); conf = gson.fromJson(configStr, conf.getClass()); log.info("request: {}", request); log.info("response: {}", response); /* * You can use the parameters in the configuration. */ // note: the path to the rewrite must start with '/' // request.setPath((String) conf.get("rewrite_path")); // request.setHeader((String) conf.get("conf_header_name"), (String) conf.get("conf_header_value")); // request.setHeader("para_test", "ning_test"); request.setPath((String) conf.get("rewrite_path")); request.setHeader((String) conf.get("conf_header_name"), (String) conf.get("conf_header_value")); return chain.filter(request, response); } } -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
