Giter Site home page Giter Site logo

bellmit / gateway Goto Github PK

View Code? Open in Web Editor NEW

This project forked from weweibuy/gateway

0.0 0.0 0.0 562 KB

Springcloud gateway 的样例工程, 封装了一些常用的网关功能,如鉴权,数据级权限控制,验签,动态路由,日志,流控,降级等

Java 99.93% FreeMarker 0.07%

gateway's Introduction

gateway

SpringCloud Gateway 的样例工程,使用响应式编程,包含功能:

  • 鉴权
  • 数据级权限控制
  • 验签
  • 动态路由
  • 日志与APM
  • 流控,降级
注意: 该项目对 weweibuy-framework项目有依赖,直接打开会报错,需要先下载:

weweibuy-framework 然后 mvn install
本地启动时设置环境变量: -Dspring.profiles.active=dev

1. 鉴权:

支持功能:

2. 数据级权限控制:

参考: DataPermissionGatewayFilterFactory

3. 验签:

对业务请求参数无侵入,无需特意改变请求/响应报文的验签
支持功能:

  • GET请求验签
  • Json请求验签
  • application/x-www-form-urlencoded 验签
  • 文件上传请求验签

参考: SystemRequestParamGatewayFilterFactory VerifySignatureGatewayFilterFactory

4. 动态路由:

基于JDBC + Mybatis 动态路由,路由/断言/过滤参数灵活配置:
数据库脚本: router.sql
功能实现:
参考: JdbcRouteDefinitionLocator JdbcRouterManger
查询与刷新路由服务端点: JdbcRouterManger

5. 日志与 APM

基础的日志输出功能,类似AccessLog;
日志参考: AccessLogFilter
APM参考: AddTraceHeaderGatewayFilterFactory

6. 流控,降级

参考: Sentinel SentinelGatewayFilterFactory

7. 负载均衡

ILoadBalancer对服务有自己的缓存,定时(默认30s)到注册中心更新缓存的服务信息. 当服务下线时,如果本地缓存不清除,将导致将请求转发到一个不可用的服务上,直到下次定时更新服务. 可以通过注册中心监听服务健康状态(例如consul的watches),通知一个MQ服务,gateway监听MQ消息刷新本地缓存服务信息 参考: RocketServerChangeListener

gateway's People

Contributors

weweibuy avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.