# 微信API网关 **Repository Path**: yangmain/wechat_api_gateway ## Basic Information - **Project Name**: 微信API网关 - **Description**: 微信API网关,通过使用微信公众号、服务注册&发现、反向代理等等插件的组合,来有效解决来自不同客户端和服务器请求的统一接入、分发、监控等问题 - **Primary Language**: NodeJS - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 28 - **Created**: 2019-11-11 - **Last Updated**: 2020-12-20 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 微信API网关 ======= 一、功能说明 ------ 本项目是基于koa2框架实现的API网关,使用koa2框架的中间件机制提供插件功能。 通过使用微信公众号、服务注册&发现、反向代理等等插件的组合,来有效解决来自不同客户端和服务器请求的统一接入、分发、监控等问题。 支持自定义插件。  --------------------------------- 二、环境说明 ------ [NodeJS v8.x.x](https://nodejs.org/en/) --------------------------------- 三、插件说明 ------ **1. 原理说明** 接收请求后,通过管道机制,把请求、响应、会话、日志等对象封装成管道对象,逐一传给每个插件,每个插件都是单一职责的,一项功能由多个插件的组合来实现,并且可以调整插件的组合来实现不同的功能,例如,[微信网关](https://gitee.com/libfintech/api_gateway_plugin/tree/master/wx_gateway)插件只负责微信消息格式的转换,配合[转移请求](https://gitee.com/libfintech/api_gateway_plugin/tree/master/transfer)和[反向代理](https://gitee.com/libfintech/api_gateway_plugin/tree/master/proxy)插件,完成分发请求至不同服务器的功能 下图为管道机制原理图,其中必须[配置和启用](https://gitee.com/libfintech/wechat_api_gateway/blob/master/app_config.js.example)反向代理(proxy)插件  **2. 使用说明** 参考[API网关插件库](https://gitee.com/libfintech/api_gateway_plugin) --------------------------------- 四、应用配置说明 -------- 复制[app_config.js.example](https://gitee.com/libfintech/wechat_api_gateway/blob/master/app_config.js.example)为app_config.js,保存到项目根目录中 example中已配置好的插件如下: - [日志追踪](https://gitee.com/libfintech/api_gateway_plugin/tree/master/log_trace) - [IP白名单&黑名单](https://gitee.com/libfintech/api_gateway_plugin/tree/master/ip) - [认证](https://gitee.com/libfintech/api_gateway_plugin/tree/master/authe) - [微信网关](https://gitee.com/libfintech/api_gateway_plugin/tree/master/wx_gateway) - [转移请求](https://gitee.com/libfintech/api_gateway_plugin/tree/master/transfer) - [反向代理](https://gitee.com/libfintech/api_gateway_plugin/tree/master/proxy) - [微信网关响应](https://gitee.com/libfintech/api_gateway_plugin/tree/master/wx_gateway_response) 具体配置参数如下:
port | 应用端口 |
log |
rootPath:日志根路径,可自定义,如,/xxx/xxx/wechat_api_gateway
日志追踪id键,可自定义,下面三个取值为Spring Cloud Sleuth的默认值
traceIdKey:x-b3-traceid,
spanIdKey:x-b3-spanid,
parentSpanIdKey:x-b3-parentspanid
|
runningMode | 运行模式,单机模式(standalone)、集群模式(cluster) |
mpConfigName | 公众号配置名称,单机模式时,为配置文件名,集群模式时,为redis key |
redis |
redis配置,单机模式时,忽略,集群模式时,必须配置
ip: IP地址
port:端口
pass:密码
|
plugins |
插件配置列表,配置顺序决定触发顺序
path:插件路径
config_path:插件配置目录
enable:是否启用
|