OpenrestyChina一个Merge引起的BUG
作者:糖果
因为在对应一个issue时,遗漏了reset_last_reply的最后一个形参last_reply_time,造成了主页列表的最后回复人无法显示。
function topic_model:reset_last_reply(topic_id, user_id, user_name, last_reply_time) -- 更新最后回复人
local now = utils.now()
db:query("update topic set last_reply_id=?, last_reply_name=?, last_reply_time=? where id=?",
{tonumber(user_id), user_name, last_reply_time, tonumber(topic_id)})
end
后来因为这个问题,不引发了一个计论就是,LOR到底是不是MVC结构的,或是说到底有没有C控制。
Lapis如何读写HTTP的Header数据
by 糖果
这不是翻译的文章,其中直接用了我的理解,进行功能的描述。
How do I read a HTTP header?
如何读取HTTP的Header数据
The req field of the self passed to actions has a headers fields with all the request headers. They are normalized so you don’t have to be concerned about capitalization.
在Lapis中headers数据,直接存于self.req.headers数据结构中,可以像访问map一样,用key取得对应的字段值,代码如下:
local lapis = require("lapis")
local app = lapis.Application()
app:match("/", function(self)
return self.req.headers["referrer"]
end)
How do I write a HTTP header?
如何向H ...
深入探究MoonScript的类实现
(An in-depth look into the MoonScript class implementation)
Posted July 05, 2015 by leafo (@moonscript) · Tags: lua, moonscript
Tweet
MoonScript’s class system is great balance of functionality and brevity. It’s simple to get started with, doesn’t impose many restrictions, and is incredibly flexible when you need to do advanced things or bend the rules.
MoonScript的类系统功能设计的简洁明了,容易上手,无过多的牵绊, 是一款可以方便灵活使用的高级货。
Even if you have no intention of using MoonScript, understanding the class system implem ...
用ORC自动生成的OpenResty配置文件和目录结构
作者:糖果
ORC是LOR的本地改动版,可以通简单的命令快速的生成Openresty的配置文件和目录结构:
安装ORC,然后执行下下面的操作:
1.安装
sudo sh install.sh
2.生成工程
orc project testcase
3.控制工程
进入testcase目录
orc start dev
orc stop dev
orc reload dev
test
作者:糖果
因为在对应一个issue时,遗漏了reset_last_reply的最后一个形参last_reply_time,造成了主页列表的最后回复人无法显示。
function topic_model:reset_last_reply(topic_id, user_id, user_name, last_reply_time) -- 更新最后回复人
local now = utils.now()
db:query("update topic set last_reply_id=?, last_reply_name=?, last_reply_time=? where id=?",
{tonumber(user_id), user_name, last_reply_time, tonumber(topic_id)})
end
后来因为这个问题,不引发了一个计论就是,LOR到底是不是MVC结构的,或是说到底有没有C控制。
usages
category: Guides
redirect_from:
- /docs/v0.4.0/guides/usages/
- /docs/latest/guides/usages/
title: “使用场景”
sort_title: “2”
Orange是基于插件设计的,基本思想是通过实现各种插件灵活的在Nginx的各个执行阶段进行逻辑处理。
Orange提供的默认插件功能如下:
全局的监控插件,可统计API访问情况、Nginx连接情况、流量统计、QPS等
自定义监控,可根据配置的规则筛选监控项,统计其各个指标
rewrite插件,可通过UI配置各种rewrite策略,省去手写nginx rewrite,然后重启的麻烦
redirect插件,实现请求重定向功能
HTTP Basic Authorization,为API动态配置鉴权
简单地WAF应用防火墙,可提取各个请求参数,通过各种匹配规则甄别需要禁止的流量
分流插件,可分为三个使用场景:
作为proxy,如代理后端的多个HTTP应用
用于AB测试
用于动态分流,API版本控制等
其它插件,用 ...
issues
category: Guides
redirect_from:
- /docs/v0.4.0/guides/issues/
- /docs/latest/guides/issues/
title: “常见问题”
sort_title: “3”
Orange依赖的OpenResty版本是多少?
Orange的监控插件需要统计http的某些状态数据,所以需要编译OpenResty时添加--with-http_stub_status_module。由于使用了*_block指令,所以OpenResty的版本最好在1.9.7.3以上.
start.sh脚本无法启动
检查OpenResty和lor是否安装成功。命令行要能直接执行Nginx -v和lord -v,并且Orange依赖的OpenResty版本应在1.9.7.3++,lor版本在v0.1.0+
找不到libuuid.so
Orange现在依赖libuuid来生成规则id,centos用户可尝试使用yum install libuuid-devel安装,其他用户请自行google对应平台的安装方式。
默认的Dashboard ...
contributing.md
category: Guides
redirect_from:
- /docs/v0.4.0/guides/contributing/
- /docs/latest/guides/contributing/
title: “参与开发”
sort_title: “5”
如何做?
Fork 源码
克隆Fork后的仓库至你的电脑
$ git clone https://github.com/<username>/orange.git
创建一个特性分支
$ git checkout -b new_feature
在new_feature分支上对Orange进行修改
提交分支:
$ git push origin new_feature
创建pull request, 并描述具体的改动
注意事项
应详细描述所做改动要解决的问题
在收到PR时会第一时间审核并Merge你的改动,请确保改动的地方不存在排版等问题
问题反馈
在使用Orange过程中碰到任何问题,可以到 GitHub 上提问
贡献者
排名不分先后。
sumory
ORC的启动脚本的封装脚本
这种是在生成shell的方式时,都shell的一种封装,尽量在shell用上去,看着简洁点。
#####################################################################
# usage:
# sh start.sh -- start application @dev ...
condition.md
category: Concept
redirect_from:
- /docs/v0.4.0/concept/condition/
- /docs/latest/concept/condition/
title: “匹配条件”
sort_title: “5”
每个条件的格式如下:
{
"type": "",
"operator": "",
"name":"", //可能为空
"value": ""
}
实例:
{
"type": "Header",
"operator": "=",
"name": "uid",
"value": "123"
& ...


