API
网关。这是一个异步的,高性能的,跨语言的,响应式的 API
网关。
ShenYu(神禹)是中国古代君主夏禹(后世亦称大禹)的尊称,他留下了三渡黄河造福人民并成功治理黄河洪水的感人故事。他和尧、舜一起被认为是中国古代三大帝王之一。
> docker pull apache/shenyu-admin > docker network create shenyu > docker run -d -p 9095:9095 --net shenyu apache/shenyu-admin
默认账号: admin
默认密码: 123456
> docker network create shenyu > docker pull apache/shenyu-bootstrap > docker run -d -p 9195:9195 --net shenyu apache/shenyu-bootstrap
{ "name" : "Shenyu", "data" : "hello world" }
将localKey: 123456
添加到Headers中。如果需要自定义localKey,可以使用sha512工具基于明文生成密钥,并更新shenyu.local.sha512Key
属性。
curl --location --request POST 'http://localhost:9195/shenyu/plugin/selectorAndRules' \ --header 'Content-Type: application/json' \ --header 'localKey: 123456' \ --data-raw '{ "pluginName": "divide", "selectorHandler": "[{\"upstreamUrl\":\"127.0.0.1:8080\"}]", "conditionDataList": [{ "paramType": "uri", "operator": "match", "paramValue": "/**" }], "ruleDataList": [{ "ruleHandler": "{\"loadBalance\":\"random\"}", "conditionDataList": [{ "paramType": "uri", "operator": "match", "paramValue": "/**" }] }] }'
{ "name" : "Shenyu", "data" : "hello world" }
每当有请求进来,Apache ShenYu将基于责任链模式由所有启用的插件来执行它。
作为Apache ShenYu的核心,插件是可扩展和可热插拔的。
不同的插件做不同的事情。
当然,用户也可以自定义插件来满足自己的需求。
如果要自定义,见自定义插件
根据您的HTTP请求头,Selector和Rule将用于路由您的请求。
Selector是您的第一层路由,它是粗粒度的,例如模块级。
Rule是你的第二层路由,你认为你的请求应该做什么。例如模块中的方法级别。
Selector和Rule只匹配一次,然后返回匹配结果。因此最粗的粒度应该最后排序。
因为所有数据都是使用JVM中的ConcurrentHashMap缓存的,所以速度非常快。
Apache ShenYu通过监听ZooKeeper节点(或WebSocket push,HTTP long polling),在后台管理中用户更改配置信息时动态更新缓存。
按注册顺序,欢迎更多接入公司在 https://github.com/apache/shenyu/issues/68 注册(仅限开源用户)。
用户 : 已知用户