Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Eolink
goku-api-gateway
提交
dcc0db4f
G
goku-api-gateway
项目概览
Eolink
/
goku-api-gateway
上一次同步 1 年多
通知
133
Star
2992
Fork
611
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
goku-api-gateway
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
dcc0db4f
编写于
5月 04, 2018
作者:
E
eoLinker API Management
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
V2.0.1
上级
1eb95c23
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
58 addition
and
46 deletion
+58
-46
README.md
README.md
+11
-1
release/goku-ce-1.0.0.zip
release/goku-ce-1.0.0.zip
+0
-0
release/goku-ce-1.0.2.zip
release/goku-ce-1.0.2.zip
+0
-0
release/goku_ce_1.0.1.zip
release/goku_ce_1.0.1.zip
+0
-0
release/goku_ce_1.0.3.zip
release/goku_ce_1.0.3.zip
+0
-0
release/goku_ce_2.0.1.zip
release/goku_ce_2.0.1.zip
+0
-0
source_code/conf/parse_config.go
source_code/conf/parse_config.go
+9
-8
source_code/middleware/request_mapping.go
source_code/middleware/request_mapping.go
+38
-37
未找到文件。
README.md
浏览文件 @
dcc0db4f
...
...
@@ -122,4 +122,14 @@ GoKu API Gateway CE,支持OpenAPI与微服务管理,支持私有云部署,
优化:
1.
架构优化,减少第三方依赖,提升网关性能;
2.
弃置mysql、redis数据库的使用,改用配置文件方式读取文件配置。
\ No newline at end of file
2.
弃置mysql、redis数据库的使用,改用配置文件方式读取文件配置。
#### V2.0.1(2018/5/4)
优化:
1.
优化网关的错误提示。
修复:
1.
修复访问网关根路径时,报越界错误。
\ No newline at end of file
release/goku-ce-1.0.0.zip
已删除
100644 → 0
浏览文件 @
1eb95c23
文件已删除
release/goku-ce-1.0.2.zip
已删除
100644 → 0
浏览文件 @
1eb95c23
文件已删除
release/goku
-ce-
1.0.1.zip
→
release/goku
_ce_
1.0.1.zip
浏览文件 @
dcc0db4f
文件已移动
release/goku
-ce-
1.0.3.zip
→
release/goku
_ce_
1.0.3.zip
浏览文件 @
dcc0db4f
文件已移动
release/goku
-ce-2.0.0
.zip
→
release/goku
_ce_2.0.1
.zip
浏览文件 @
dcc0db4f
无法预览此类型文件
source_code/conf/parse_config.go
浏览文件 @
dcc0db4f
...
...
@@ -32,11 +32,12 @@ func getGatewayList(path []string) []GatewayInfo {
var
gateway
GatewayInfo
c
,
err
:=
ioutil
.
ReadFile
(
p
+
PthSep
+
"gateway.conf"
)
if
err
!=
nil
{
panic
(
"Error gateway config path!"
)
panic
(
"Error gateway config path! Error path: "
+
p
)
}
err
=
yaml
.
Unmarshal
(
c
,
&
gateway
)
if
err
!=
nil
{
panic
(
"Error gateway config!
"
)
panic
(
"Error gateway config!
Error path: "
+
p
)
}
if
gateway
.
GatewayStatus
!=
"on"
{
continue
...
...
@@ -53,11 +54,11 @@ func getStrategyList(path string) Strategy {
var
strategy
Strategy
c
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
panic
(
"Error strategy config path!
"
)
panic
(
"Error strategy config path!
Error path: "
+
path
)
}
err
=
yaml
.
Unmarshal
(
c
,
&
strategy
)
if
err
!=
nil
{
panic
(
"Error strategy config!
"
)
panic
(
"Error strategy config!
Error path: "
+
path
)
}
return
strategy
}
...
...
@@ -66,11 +67,11 @@ func getApiList(path string) Api {
var
api
Api
c
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
panic
(
"Error api config path!
"
)
panic
(
"Error api config path!
Error path: "
+
path
)
}
err
=
yaml
.
Unmarshal
(
c
,
&
api
)
if
err
!=
nil
{
panic
(
"Error api config!
"
)
panic
(
"Error api config!
Error path: "
+
path
)
}
return
api
}
...
...
@@ -79,11 +80,11 @@ func getBackendList(path string) Backend {
var
backend
Backend
c
,
err
:=
ioutil
.
ReadFile
(
path
)
if
err
!=
nil
{
panic
(
"Error
api config path!"
)
panic
(
"Error
backend config path! Error path: "
+
path
)
}
err
=
yaml
.
Unmarshal
(
c
,
&
backend
)
if
err
!=
nil
{
panic
(
"Error
api config!"
)
panic
(
"Error
backend config! Error path: "
+
path
)
}
return
backend
}
source_code/middleware/request_mapping.go
浏览文件 @
dcc0db4f
...
...
@@ -15,44 +15,45 @@ func Mapping(g *goku.Goku,res http.ResponseWriter, req *http.Request) (bool,stri
if
requestURI
[
1
]
==
""
{
res
.
WriteHeader
(
404
)
res
.
Write
([]
byte
(
"Lack gatewayAlias"
))
}
else
{
return
false
,
"Lack gatewayAlias"
res
.
WriteHeader
(
404
)
return
false
,
"Lack StrategyKey"
}
}
else
{
res
.
WriteHeader
(
404
)
res
.
Write
([]
byte
(
"Lack StrategyID"
))
return
false
,
"Lack StrategyID"
}
gatewayAlias
:=
requestURI
[
1
]
strategyKey
:=
requestURI
[
2
]
urlLen
:=
len
(
gatewayAlias
)
+
len
(
strategyKey
)
+
2
flag
:=
false
for
_
,
m
:=
range
g
.
ServiceConfig
.
GatewayList
{
if
m
.
GatewayAlias
==
gatewayAlias
{
for
_
,
i
:=
range
m
.
StrategyList
.
Strategy
{
if
i
.
StrategyID
==
strategyKey
{
flag
=
true
f
,
r
:=
IPLimit
(
m
,
i
,
res
,
req
)
if
!
f
{
res
.
Write
([]
byte
(
r
))
return
false
,
r
}
}
gatewayAlias
:=
requestURI
[
1
]
StrategyID
:=
requestURI
[
2
]
urlLen
:=
len
(
gatewayAlias
)
+
len
(
StrategyID
)
+
2
flag
:=
false
for
_
,
m
:=
range
g
.
ServiceConfig
.
GatewayList
{
if
m
.
GatewayAlias
==
gatewayAlias
{
for
_
,
i
:=
range
m
.
StrategyList
.
Strategy
{
if
i
.
StrategyID
==
StrategyID
{
flag
=
true
f
,
r
:=
IPLimit
(
m
,
i
,
res
,
req
)
if
!
f
{
res
.
Write
([]
byte
(
r
))
return
false
,
r
}
f
,
r
=
Auth
(
i
,
res
,
req
)
if
!
f
{
res
.
Write
([]
byte
(
r
))
return
false
,
r
}
f
,
r
=
Auth
(
i
,
res
,
req
)
if
!
f
{
res
.
Write
([]
byte
(
r
))
return
false
,
r
}
f
,
r
=
RateLimit
(
g
,
i
)
if
!
f
{
res
.
Write
([]
byte
(
r
))
return
false
,
r
}
break
f
,
r
=
RateLimit
(
g
,
i
)
if
!
f
{
res
.
Write
([]
byte
(
r
))
return
false
,
r
}
break
}
}
}
if
flag
{
for
_
,
i
:=
range
m
.
ApiList
.
Apis
{
}
}
if
flag
{
for
_
,
i
:=
range
m
.
ApiList
.
Apis
{
if
i
.
RequestURL
==
url
[
urlLen
:
]{
// 验证请求
if
!
validateRequest
(
i
,
req
){
...
...
@@ -65,8 +66,8 @@ func Mapping(g *goku.Goku,res http.ResponseWriter, req *http.Request) (bool,stri
f
,
r
:=
GetBackendInfo
(
i
.
BackendID
,
m
.
BackendList
)
if
!
f
{
res
.
WriteHeader
(
404
)
res
.
Write
([]
byte
(
"Backend config
are
not exist!"
))
return
false
,
"Backend config
are
not exist!"
res
.
Write
([]
byte
(
"Backend config
is
not exist!"
))
return
false
,
"Backend config
is
not exist!"
}
...
...
@@ -80,7 +81,7 @@ func Mapping(g *goku.Goku,res http.ResponseWriter, req *http.Request) (bool,stri
return
true
,
string
(
response
)
}
}
}
}
}
res
.
Write
([]
byte
(
"URI Not Found"
))
return
false
,
"URI Not Found"
...
...
@@ -127,7 +128,7 @@ func CreateRequest(api conf.ApiInfo,i conf.BackendInfo,httpRequest *http.Request
}
if
param
==
nil
{
if
reqParam
.
NotEmpty
{
return
400
,
[]
byte
(
"
m
issing required parameters"
),
make
(
map
[
string
][]
string
)
return
400
,
[]
byte
(
"
M
issing required parameters"
),
make
(
map
[
string
][]
string
)
}
else
{
continue
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录