开一个网站需要什么手续,百度明令禁止搜索的词,wordpress 动态标签云,广州网站建设藤虎网络推荐一个 比 spring cloud 更好用的 API 网关。它是一个低代码 API 网关。
https://github.com/fiber-net-gateway/fiber-net-gateway
特性
同样是使用 java 开发#xff0c;相比与 SpringCloud Zuul#xff0c;它有很多 鲜明的特点。
低代码
它实现了一个灵活好用的脚本…推荐一个 比 spring cloud 更好用的 API 网关。它是一个低代码 API 网关。
https://github.com/fiber-net-gateway/fiber-net-gateway
特性
同样是使用 java 开发相比与 SpringCloud Zuul它有很多 鲜明的特点。
低代码
它实现了一个灵活好用的脚本 解释器interpreter、vm通过脚本代替配置文件、并且支持动态更新、对于用户来说更加灵活、更加直观。毕竟API 网关的用户都是程序员看简单的代码比看一堆复杂的 YAML 配置来得更加直观。
低开销、高性能
脚本解释器是以协程的方式运行的不占用线程资源。底层也是基于 Netty NIO 开发的除了 EVENT_LOOP 外无其它业务线程利用了 NETTY 零拷贝技术性能非常高开销很低。
轻依赖
整个项目只依赖 netty 和 jackson 两个第三方库无其它依赖。核心代码也只有 14000 行在内部实现了 虚拟机、异步带连接池的 http client http server依赖注入、reactive 异步事件等特性非常利用阅读和学习。
快速使用
编译
git clone https://github.com/fiber-net-gateway/fiber-net-gateway.git
cd fiber-net-gateway
mvn package -DskipTests
cd fiber-gateway-example/target
创建配置(脚本)文件
mkdir conf
cat conf/fiber-net.gs EOF
directive fy from http https://fanyi.baidu.com;
directive bd from http https://www.baidu.com;
if(req.getMethod() POST) {fy.proxyPass({path: /v2transapi,query: fromentozh,method: POST,headers: {X-Fiber-Project: null}});
} else {let res bd.request({path: /, headers: {User-Agent: curl/7.88.1}});resp.setHeader(Content-Type, text/html);resp.send(res.status, res.body);
}
EOF
运行
java -jar fiber-gateway-example-1.0-SNAPSHOT.jar conf
测试
# 使用 post 请求反向代理到百度翻译 反向代理会透传 downstream 内容
curl 127.0.0.1:16688 -XPOST
# 使用其它请求返回百度主页。请求模式不会透传 downstream。
curl 127.0.0.1:16688 -XGET
返回内容
$ curl 127.0.0.1:16688 -i
HTTP/1.1 200 OK
Content-Type: text/html
date: Mon, 18 Dec 2023 14:58:40 GMT
server: fiber-net(fn)/1.0-SNAPSHOT/549a404dcaee9bc2
content-length: 2443!DOCTYPE html
!--STATUS OK--html headmeta http-equivcontent-type contenttext/html;charsetutf-8meta http-equivX-UA-Compatible contentIEEdgemeta contentalways namereferrerlink relstylesheet typetext/css hrefhttps://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/bdorz/baidu.min.csstitle百度一下你就知道/title/head body link#0000cc div idwrap idhead div classhead_wrapper div classs_form div classs_form_wrapper div idlg img hidefocustrue src//www.baidu.com/img/bd_logo1.png width270 height129 /div form idform namef action//www.baidu.com/s classfm input typehidden namebdorz_come value1 input typehidden nameie valueutf-8 input typehidden namef value8 input type
hidden namersv_bp value1 input typehidden namersv_idx value1 input typehidden nametn valuebaiduspan classbg s_ipt_wrinput idkw namewd classs_ipt value m m
axlength255 autocompleteoff autofocusautofocus/spanspan classbg s_btn_wrinput typesubmit idsu value百度一下 classbg s_btn autofocus/span /form /div /div di
v idu1 a hrefhttp://news.baidu.com nametj_trnews classmnav新闻/a a hrefhttps://www.hao123.com nametj_trhao123 classmnavhao123/a a hrefhttp://map.baidu.com nametj_tr
map classmnav地图/a a hrefhttp://v.baidu.com nametj_trvideo classmnav视频/a a hrefhttp://tieba.baidu.com nametj_trtieba classmnav贴吧/a noscript a hrefhttp://www
.baidu.com/bdorz/login.gif?loginamp;tplmnamp;uhttp%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 nametj_login classlb登录/a /noscript scriptdocument.write(a hrefhttp://ww
w.baidu.com/bdorz/login.gif?logintplmnu encodeURIComponent(window.location.href (window.location.search ? ? : ) bdorz_come1) nametj_login classlb登录/a);/script a href//www.baidu.com/more/ nametj_briicon classbri styledisplay: block;更多产品/a /div /div /div div idftCon div idftConw p idlh ahrefhttp://home.baidu.com关于百度/a a hrefhttp://ir.baidu.comAbout Baidu/a /p p idcpcopy;2017nbsp;Baidunbsp;a hrefhttp://www.baidu.com/duty/使用百度前必读/anbsp; a hrefhttp://jianyi.baidu.com/ classcp-feedback意见反馈/anbsp;京ICP证030173号nbsp; img src//www.baidu.com/img/gs.gif /p /div /div /div /body /html
每次请求fiber-net.gs 都会被执行一次。也可以在 conf 目录下放置其它 .gs 文件 通过 request header X-Fiber-Project 执行被执行的文件名。如 ttt.gs
### conf/ttt.gs 文件会被执行不指定则执行 fiber-net.gs
curl 127.0.0.1:16688 -HX-Fiber-Project: ttt