Skip to content

Commit 35d886a

Browse files
committed
bump version to v0.6.2 to make it compatible with lor v0.3.*
1 parent f1f5c07 commit 35d886a

File tree

8 files changed

+343
-35
lines changed

8 files changed

+343
-35
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
### v0.6.2 2017.02.18
2+
3+
- 兼容Orange与最新版本的[lor]https://github.com/sumory/lor), 即lor v0.3.0
4+
5+
注意:
6+
7+
- 若使用的Orange版本在0.6.2以下,则应安装lor v0.2.*版本, 推荐lor v0.2.6
8+
- 若使用的Orange版本在0.6.2及以上,可升级lor到v0.3.0+版本
9+
110
### v0.6.1 2017.02.09
211

312
添加property based rate limiting插件,该插件由[@noname007](https://github.com/noname007)贡献

README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ A Gateway based on OpenResty(Nginx+lua) for API Monitoring and Management.
1515
- MySQL v5.5+
1616
- OpenResty v1.9.7.3+ or Nginx+lua module
1717
- install OpenResty with `--with-http_stub_status_module` option
18-
- [Lor Framework](https://github.com/sumory/lor) v0.2.6, **not compatible** with lor v0.3.0 for now.
18+
- [Lor Framework](https://github.com/sumory/lor) please mind:
19+
- Orange v0.6.1 and versions before v0.6.1 are compatible with lor v0.2.*
20+
- Orange v0.6.2+ is compatible with lor v0.3.0+
1921

20-
Import the SQL file(e.g. install/orange-v0.6.1.sql) which is adapted to your Orange version to MySQL database named `orange`.
22+
Import the SQL file(e.g. install/orange-v0.6.2.sql) which is adapted to your Orange version into MySQL database named `orange`.
2123

2224
#### Install
2325

README_zh.md

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ Orange是一个基于OpenResty的API网关。除Nginx的基本功能外,它还
1919
- OpenResty: 版本应在1.9.7.3+
2020
- Orange的监控插件需要统计http的某些状态数据,所以需要编译OpenResty时添加`--with-http_stub_status_module`
2121
- 由于使用了*_block指令,所以OpenResty的版本最好在1.9.7.3以上.
22-
- [lor](https://github.com/sumory/lor)框架: 版本v0.2.6
23-
- 暂时与lor v0.3.0(即master版本)不兼容
24-
- 下载0.2.6版本的release包,解压到lor文件夹
25-
- cd lor && sh install.sh
22+
- [lor](https://github.com/sumory/lor)框架
23+
- 若使用的Orange版本低于v0.6.2则应安装lor v0.2.*版本
24+
- 若使用的Orange版本高于或等于v0.6.2则应安装lor v0.3.0+版本
2625
- MySQL
2726
- 配置存储和集群扩展需要MySQL支持。从0.2.0版本开始,Orange去除了本地文件存储的方式,目前仅提供MySQL存储支持.
2827

2928
#### 数据表导入MySQL
3029

3130
- 在MySQL中创建数据库,名为orange
32-
- 将与当前代码版本配套的SQL脚本(如install/orange-v0.6.1.sql)导入到orange库中
31+
- 将与当前代码版本配套的SQL脚本(如install/orange-v0.6.2.sql)导入到orange库中
3332

3433
#### 修改配置文件
3534

@@ -45,10 +44,12 @@ orange.conf的配置如下,请按需修改:
4544
"redirect",
4645
"rewrite",
4746
"rate_limiting",
47+
"property_rate_limiting",
4848
"basic_auth",
4949
"key_auth",
5050
"waf",
51-
"divide"
51+
"divide",
52+
"kvstore"
5253
],
5354

5455
"store": "mysql",//目前仅支持mysql存储

api/server.lua

+6-9
Original file line numberDiff line numberDiff line change
@@ -64,29 +64,26 @@ function _M:build_app()
6464
end
6565
end
6666
end
67-
67+
6868
auth_failed(res)
6969
end)
7070

7171
-- routes
7272
app:use(router(config, store)())
7373

74-
-- 404 error
75-
app:use(function(req, res, next)
74+
-- error handle middleware
75+
app:erroruse(function(err, req, res, next)
76+
ngx.log(ngx.ERR, err)
7677
if req:is_found() ~= true then
77-
res:status(404):json({
78+
return res:status(404):json({
7879
success = false,
7980
msg = "404! sorry, not found."
8081
})
8182
end
82-
end)
8383

84-
-- error handle middleware
85-
app:erroruse(function(err, req, res, next)
86-
ngx.log(ngx.ERR, err)
8784
res:status(500):json({
8885
success = false,
89-
msg = "500! unknown error."
86+
msg = "500! server error."
9087
})
9188
end)
9289
end

dashboard/routes/auth.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ return function(config, store)
4949
if result and not err then
5050
if result and #result == 1 then
5151
isExist = true
52-
user = result[1]
52+
user = result[1]
5353
userid = user.id
5454
end
5555
else
@@ -91,7 +91,7 @@ return function(config, store)
9191
res.locals.userid = 0
9292
res.locals.create_time = ""
9393
req.session.destroy()
94-
res:redirect("/login")
94+
res:redirect("/auth/login")
9595
end)
9696

9797

dashboard/server.lua

+13-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
local string_find = string.find
2+
local setmetatable = setmetatable
23
local session_middleware = require("lor.lib.middleware.session")
34
local check_login_middleware = require("dashboard.middleware.check_login")
45
local check_is_admin_middleware = require("dashboard.middleware.check_is_admin")
@@ -53,32 +54,29 @@ function _M:build_app()
5354
-- routes
5455
app:use(dashboard_router(config, store)())
5556

56-
-- 404 error
57-
app:use(function(req, res, next)
57+
-- error handle middleware
58+
app:erroruse(function(err, req, res, next)
59+
ngx.log(ngx.ERR, err)
60+
local is_json_accept = string_find(req.headers["Accept"], "application/json")
61+
5862
if req:is_found() ~= true then
59-
if string_find(req.headers["Accept"], "application/json") then
60-
res:status(404):json({
63+
if is_json_accept then
64+
return res:status(404):json({
6165
success = false,
6266
msg = "404! sorry, not found."
6367
})
64-
else
65-
res:status(404):send("404! sorry, not found. " .. req.path or "")
6668
end
69+
return res:status(404):send("404! sorry, not found. " .. (req.path or ""))
6770
end
68-
end)
6971

70-
-- error handle middleware
71-
app:erroruse(function(err, req, res, next)
72-
ngx.log(ngx.ERR, err)
73-
74-
if string_find(req.headers["Accept"], "application/json") then
75-
res:status(500):json({
72+
if is_json_accept then
73+
return res:status(500):json({
7674
success = false,
7775
msg = "500! unknown error."
7876
})
79-
else
80-
res:status(500):send("unknown error")
8177
end
78+
79+
res:status(500):send("unknown error")
8280
end)
8381
end
8482

0 commit comments

Comments
 (0)