Skip to content

Commit

Permalink
bump version to v0.6.2 to make it compatible with lor v0.3.*
Browse files Browse the repository at this point in the history
  • Loading branch information
sumory committed Feb 18, 2017
1 parent f1f5c07 commit 35d886a
Show file tree
Hide file tree
Showing 8 changed files with 343 additions and 35 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
### v0.6.2 2017.02.18

- 兼容Orange与最新版本的[lor]https://github.com/sumory/lor), 即lor v0.3.0

注意:

- 若使用的Orange版本在0.6.2以下,则应安装lor v0.2.*版本, 推荐lor v0.2.6
- 若使用的Orange版本在0.6.2及以上,可升级lor到v0.3.0+版本

### v0.6.1 2017.02.09

添加property based rate limiting插件,该插件由[@noname007](https://github.com/noname007)贡献
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ A Gateway based on OpenResty(Nginx+lua) for API Monitoring and Management.
- MySQL v5.5+
- OpenResty v1.9.7.3+ or Nginx+lua module
- install OpenResty with `--with-http_stub_status_module` option
- [Lor Framework](https://github.com/sumory/lor) v0.2.6, **not compatible** with lor v0.3.0 for now.
- [Lor Framework](https://github.com/sumory/lor) please mind:
- Orange v0.6.1 and versions before v0.6.1 are compatible with lor v0.2.*
- Orange v0.6.2+ is compatible with lor v0.3.0+

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

#### Install

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

#### 数据表导入MySQL

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

#### 修改配置文件

Expand All @@ -45,10 +44,12 @@ orange.conf的配置如下,请按需修改:
"redirect",
"rewrite",
"rate_limiting",
"property_rate_limiting",
"basic_auth",
"key_auth",
"waf",
"divide"
"divide",
"kvstore"
],

"store": "mysql",//目前仅支持mysql存储
Expand Down
15 changes: 6 additions & 9 deletions api/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,29 +64,26 @@ function _M:build_app()
end
end
end

auth_failed(res)
end)

-- routes
app:use(router(config, store)())

-- 404 error
app:use(function(req, res, next)
-- error handle middleware
app:erroruse(function(err, req, res, next)
ngx.log(ngx.ERR, err)
if req:is_found() ~= true then
res:status(404):json({
return res:status(404):json({
success = false,
msg = "404! sorry, not found."
})
end
end)

-- error handle middleware
app:erroruse(function(err, req, res, next)
ngx.log(ngx.ERR, err)
res:status(500):json({
success = false,
msg = "500! unknown error."
msg = "500! server error."
})
end)
end
Expand Down
4 changes: 2 additions & 2 deletions dashboard/routes/auth.lua
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ return function(config, store)
if result and not err then
if result and #result == 1 then
isExist = true
user = result[1]
user = result[1]
userid = user.id
end
else
Expand Down Expand Up @@ -91,7 +91,7 @@ return function(config, store)
res.locals.userid = 0
res.locals.create_time = ""
req.session.destroy()
res:redirect("/login")
res:redirect("/auth/login")
end)


Expand Down
28 changes: 13 additions & 15 deletions dashboard/server.lua
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
local string_find = string.find
local setmetatable = setmetatable
local session_middleware = require("lor.lib.middleware.session")
local check_login_middleware = require("dashboard.middleware.check_login")
local check_is_admin_middleware = require("dashboard.middleware.check_is_admin")
Expand Down Expand Up @@ -53,32 +54,29 @@ function _M:build_app()
-- routes
app:use(dashboard_router(config, store)())

-- 404 error
app:use(function(req, res, next)
-- error handle middleware
app:erroruse(function(err, req, res, next)
ngx.log(ngx.ERR, err)
local is_json_accept = string_find(req.headers["Accept"], "application/json")

if req:is_found() ~= true then
if string_find(req.headers["Accept"], "application/json") then
res:status(404):json({
if is_json_accept then
return res:status(404):json({
success = false,
msg = "404! sorry, not found."
})
else
res:status(404):send("404! sorry, not found. " .. req.path or "")
end
return res:status(404):send("404! sorry, not found. " .. (req.path or ""))
end
end)

-- error handle middleware
app:erroruse(function(err, req, res, next)
ngx.log(ngx.ERR, err)

if string_find(req.headers["Accept"], "application/json") then
res:status(500):json({
if is_json_accept then
return res:status(500):json({
success = false,
msg = "500! unknown error."
})
else
res:status(500):send("unknown error")
end

res:status(500):send("unknown error")
end)
end

Expand Down
Loading

0 comments on commit 35d886a

Please sign in to comment.