GoKu API Gateway CE配置文件

配置文件

1.GoKu拥有一个主配置文件 goku.conf ,GoKu可以新建多个网关,每个网关一个文件夹。
2.GoKu的配置文件采用 yaml 格式:

  • 大小写敏感。
  • 使用缩进表示层级关系,缩进时不允许使用Tab键,只允许使用空格。
  • 缩进的空格数无关,只需相同层级的元素左侧对齐即可。

3.修改配置文件后,重启网关以使其生效
4.配置文件的层级关系如下图所示:

这里写图片描述

参数字段表

一、goku.conf

参数名 说明 必填 类型 示例 备注
host 网关地址 string 192.168.21.222
port 端口号 string 8800
gateway_conf_path 网关所在路径 string ./config/gateway

二、gateway.conf

参数名 说明 必填 类型 示例 备注
gateway_name 网关名称 string GoKu
gateway_alias 网关别名 string goku 用于拼接网关请求地址
gateway_status 网关状态 string on on/off
ip_limit_type 开启ip黑白名单 string none 可取值:none/white/black
ip_white_list ip白名单 []string 列表
ip_black_list ip黑名单 []string 列表
strategy_conf_path 策略组所在路径 string ./config/gateway/hm/strategy.conf
api_group_conf_path API分组所在路径 string ./config/gateway/hm/api_group.conf
api_conf_path API所在路径 string ./config/gateway/hm/api.conf

三、backend.conf

参数名 说明 必填 类型 示例 备注
backend_id 后端服务id int 1 不可重复
backend_name 后端服务名称 string 开放接口
backend_path 后端服务路径 string https://api.apishop.net 不可重复

四、strategy.conf

参数名 说明 必填 类型 示例 备注
strategy_name 策略组名称 string OpenAPI
strategy_id 策略组id string sjdkjs 随机字符串,不可重复
auth 鉴权方式 string apikey 可取值:none/basic/apikey
api_key 用于apikey鉴权方式 string fd9befe929399f09c393
basic_user_name basic 用户名 string 123
basic_user_password basic密码 string 123
ip_limit_type 开启ip黑白名单 string none 可取值:none/white/black
ip_white_list ip白名单 []string 列表
ip_black_list ip黑名单 []string 列表
rate_limit_list 流量控制 []string 列表
allow 是否允许访问 bool true true/false
priority 流控优先级 int 999 流控执行优先级:0~999
start_time 流控开始时间 int 6 0~24
end_time 流控结束时间 int 22 0~24
period 流控单位 string min 可取值:sec/min/hour/day
limit 限流次数 int 1000

五、api_group.conf

参数名 说明 必填 类型 示例 备注
group_id api分组 id int 2 不可重复
group_name api分组名称 string 通用接口

六、api.conf

参数名 说明 必填 类型 示例 备注
api_name 参数名 string 查询全国油价
group_id 所属分组 int 0 0代表无分组
backend_id 对应后端服务 int 1
request_method 网关请求方式 string post 数组,可取值:get/post/put/delete/options/patch/head
request_url 网关请求路径 string /common/oil/getOilPriceToday
proxy_method 后端请求方式 string post 非数组,可取值:get/post/put/delete/options/patch/head
proxy_url 后端请求路径 string /common/oil/getOilPriceToday
proxy_body_type body类型 string formdata 可取值:formdata/raw/json
porxy_body raw数据 string
proxy_params 请求参数映射 列表
key 网关参数名 string province
key_position 网关参数位置 string body 可取值:header/body/query,当为raw数据时body不可取
not_empty 是否必填 bool
proxy_key 后端参数名 string province
proxy_key_position 后端参数位置 string body 可取值:header/body/query,当为raw数据时body不可取
constant_params 常量参数 列表
key 参数名 string apiKey
position 参数位置 string body 可取值:header/body/query,当为raw数据时body不可取
value 参数值 string 9399f09c393fd9befe92

想了解更多国内首款GO语言网关信息,请留意:https://agw.eolinker.com,或者关注本博客,博客将会及时更新eoLinker最新资讯。

猜你喜欢

转载自blog.csdn.net/qq_40579834/article/details/80250615