Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
docs: add README.md (#17)
- Loading branch information
1 parent
ce3ebda
commit 732cd2de2a3b10dc92c417933cc93eda0bd0dad2
Showing
16 changed files
with
247 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
apisix-java-plugin-runner | ||
================= | ||
|
||
Runs [Apache APISIX](http://apisix.apache.org/) plugins written in Java. | ||
Implemented as a sidecar that accompanies APISIX. | ||
|
||
 | ||
|
||
Status | ||
------ | ||
|
||
This project is currently considered experimental. | ||
|
||
Why apisix-java-plugin-runner | ||
--------------------- | ||
|
||
APISIX offers many full-featured plugins covering areas such as authentication, | ||
security, traffic control, serverless, analytics & monitoring, transformations, logging. | ||
|
||
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.6.0](https://github.com/apache/apisix/blob/master/CHANGELOG.md#260), | ||
this project is APISIX Java side implementation that supports writing plugins in java. | ||
|
||
|
||
How it Works | ||
------------- | ||
|
||
See [How it Works](./docs/how-it-works.md) to learn how apisix-java-plugin-runner collaborate | ||
with APISIX to run plugins written in java. | ||
|
||
The Internal of apisix-java-plugin-runner | ||
--------------------------------- | ||
|
||
If you're interested in the internal of apisix-java-plugin-runner, we recommend you | ||
to read the [the-internal-of-apisix-java-plugin-runner](./docs/the-internal-of-apisix-java-plugin-runner.md), | ||
it explains the details of communication and protocol conversion with APISIX. | ||
|
||
Get Involved in Development | ||
--------------------------- | ||
|
||
Welcome to make contributions, but before you start, please check out | ||
[development.md](./docs/development.md) to learn how to run and debug apisix-java-plugin-runner | ||
in your own environment. | ||
|
||
License | ||
------- | ||
|
||
[Apache 2.0 LICENSE](./LICENSE) |
Empty file.
Empty file.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* 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 org.apache.apisix.plugin.runner.HttpRequest; | ||
import org.apache.apisix.plugin.runner.HttpResponse; | ||
import org.springframework.stereotype.Component; | ||
import reactor.core.publisher.Mono; | ||
|
||
@Component | ||
public class RewriteRequestDemoFilter 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": "RewriteRequestDemoFilter", | ||
"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 "RewriteRequestDemoFilter"; | ||
} | ||
|
||
@Override | ||
public Mono<Void> filter(HttpRequest request, HttpResponse response, PluginFilterChain chain) { | ||
// note: the path to the rewrite must start with '/' | ||
request.setPath("/get"); | ||
request.setHeader("new-header", "header_by_runner"); | ||
/* note: The value of the parameter is currently a string type. | ||
If you need the json type, you need the upstream service to parse the string value to json. | ||
For example, if the arg is set as follows | ||
request.setArg("new arg", "{\"key1\":\"value1\",\"key2\":2}"); | ||
The arg received by the upstream service will be as follows | ||
"new arg": "{\"key1\":\"value1\",\"key2\":2}" | ||
*/ | ||
request.setArg("new arg", "{\"key1\":\"value1\",\"key2\":2}"); | ||
|
||
return chain.filter(request, response); | ||
} | ||
|
||
@Override | ||
public int getOrder() { | ||
//The order of filter execution in runner is determined by the order here, the smaller the order number, the higher the execution order. | ||
return 0; | ||
} | ||
} |
Oops, something went wrong.