nginx 变量 + lua
nginx是个好东西, nginx的openrtsy发行版本更是个好东西。
今天又发现个好东西 :Moochine
MOOCHINE - 一个简单的轻量级的web framework, 基于ngx_OpenResty(ngx_lua,ttp://openresty.org) 做的框架,
使用例子https://github.com/appwilldev/moochine-demo
可以让我们构建WebApp 更加的简单,具体使用方法请看具体的 moochine-demo
request对象的属性和方法
--属性
method = ngx.var.request_method -- http://wiki.nginx.org/HttpCoreModule#.24request_method
schema = ngx.var.schema -- http://wiki.nginx.org/HttpCoreModule#.24scheme
host = ngx.var.host -- http://wiki.nginx.org/HttpCoreModule#.24host
hostname = ngx.var.hostname -- http://wiki.nginx.org/HttpCoreModule#.24hostname
uri = ngx.var.request_uri -- http://wiki.nginx.org/HttpCoreModule#.24request_uri
path = ngx.var.uri -- http://wiki.nginx.org/HttpCoreModule#.24uri
filename = ngx.var.request_filename -- http://wiki.nginx.org/HttpCoreModule#.24request_filename
query_string = ngx.var.query_string -- http://wiki.nginx.org/HttpCoreModule#.24query_string
user_agent = ngx.var.http_user_agent -- http://wiki.nginx.org/HttpCoreModule#.24http_HEADER
remote_addr = ngx.var.remote_addr -- http://wiki.nginx.org/HttpCoreModule#.24remote_addr
remote_port = ngx.var.remote_port -- http://wiki.nginx.org/HttpCoreModule#.24remote_port
remote_user = ngx.var.remote_user -- http://wiki.nginx.org/HttpCoreModule#.24remote_user
remote_passwd = ngx.var.remote_passwd -- http://wiki.nginx.org/HttpCoreModule#.24remote_passwd
content_type = ngx.var.content_type -- http://wiki.nginx.org/HttpCoreModule#.24content_type
content_length = ngx.var.content_length -- http://wiki.nginx.org/HttpCoreModule#.24content_length headers = ngx.req.get_headers() -- http://wiki.nginx.org/HttpLuaModule#ngx.req.get_headers
uri_args = ngx.req.get_uri_args() -- http://wiki.nginx.org/HttpLuaModule#ngx.req.get_uri_args
post_args = ngx.req.get_post_args() -- http://wiki.nginx.org/HttpLuaModule#ngx.req.get_post_args
socket = ngx.req.socket -- http://wiki.nginx.org/HttpLuaModule#ngx.req.socket --方法
request:read_body() -- http://wiki.nginx.org/HttpLuaModule#ngx.req.read_body
request:get_uri_arg(name, default)
request:get_post_arg(name, default)
request:get_arg(name, default) request:get_cookie(key, decrypt)
request:rewrite(uri, jump) -- http://wiki.nginx.org/HttpLuaModule#ngx.req.set_uri
request:set_uri_args(args) -- http://wiki.nginx.org/HttpLuaModule#ngx.req.set_uri_args
response对象的属性和方法
--属性
headers = ngx.header -- http://wiki.nginx.org/HttpLuaModule#ngx.header.HEADER --方法
response:set_cookie(key, value, encrypt, duration, path)
response:write(content)
response:writeln(content)
response:ltp(template,data)
response:redirect(url, status) -- http://wiki.nginx.org/HttpLuaModule#ngx.redirect response:finish() -- http://wiki.nginx.org/HttpLuaModule#ngx.eof
response:is_finished()
response:defer(func, ...) -- 在response返回后执行
支持 Multi-App 与 Sub-App
nginx 变量 + lua的更多相关文章
- nginx 与 lua 开发环境搭建
首先下载最新版的 相关软件 的安装文件. nginx: http://nginx.org/en/download.html LuaJIT: http://luajit.org/download.htm ...
- Nginx 变量漫谈(八)
与 $arg_XXX 类似,我们在 (二) 中提到过的内建变量 $cookie_XXX 变量也会在名为 XXX 的 cookie 不存在时返回特殊值“没找到”: location /test ...
- Nginx 变量漫谈(七)
在 (一) 中我们提到过,Nginx 变量的值只有一种类型,那就是字符串,但是变量也有可能压根就不存在有意义的值.没有值的变量也有两种特殊的值:一种是“不合法”(invalid),另一种是“没找到”( ...
- Nginx安装lua支持
Nginx安装lua支持 需要LuaJIT-2.0.4.tar.gz,ngx_devel_kit,lua-nginx-module 1.下载安装LuaJIT-2.0.4.tar.gz wget -c ...
- nginx安装lua模块实现高并发
nginx安装lua扩展模块 1.下载安装LuaJIT-2.0.4.tar.gz wget -c http://luajit.org/download/LuaJIT-2.0.4.tar.gz tar ...
- 11: Nginx安装lua支持
1.1 Nginx 使用lua脚本 注:需要LuaJIT-2.0.4.tar.gz,ngx_devel_kit,lua-nginx-module 1.Nginx安装lua支持 wget -c http ...
- nginx 增加 lua模块
Nginx中的stub_status模块主要用于查看Nginx的一些状态信息. 本模块默认是不会编译进Nginx的,如果你要使用该模块,则要在编译安装Nginx时指定: ./configure –wi ...
- Nginx利用lua剪辑FastDFS图片
Nginx利用lua剪辑FastDFS中的图片 我们经常用FastDFS来做图片服务器,通过nginx来上传或者获取图片.本文要实现的功能是,当客户端要获取不同尺寸的图片是,lua根据url中的尺寸大 ...
- nginx与Lua执行顺序
Nginx顺序 Nginx 处理每一个用户请求时,都是按照若干个不同阶段(phase)依次处理的,而不是根据配置文件上的顺序. Nginx 处理请求的过程一共划分为 11 个阶段,按照执行顺序依次是 ...
随机推荐
- ssh整合思想 Spring与Hibernate的整合 项目在服务器启动则自动创建数据库表
Spring整合Hibernate Spring的Web项目中,web.xml文件会自动加载,以出现欢迎首页.也可以在这个文件中对Spring的配置文件进行监听,自启动配置文件, 以及之前Struts ...
- [vijos]P1979 NOIP2015 信息传递
描述 有 n 个同学(编号为 1 到 n)正在玩一个信息传递的游戏.在游戏里每人都有一个固定的信息传递对象,其中,编号为 i 的同学的信息传递对象是编号为 TiTi 的同学. 游戏开始时,每人都只知道 ...
- 【贪心 计数 倍增】bzoj4458: GTY的OJ
倍增写挂调了半个晚上 Description 身为IOI金牌的gtyzs有自己的一个OJ,名曰GOJ.GOJ上的题目可谓是高质量而又经典,他在他的OJ里面定义了一个树形的分类目录,且两个相同级别的目录 ...
- 【单调队列】P1886 滑动窗口
GET 单调队列 题目描述 现在有一堆数字共N个数字(N<=10^6),以及一个大小为k的窗口.现在这个从左边开始向右滑动,每次滑动一个单位,求出每次滑动后窗口中的最大值和最小值. 例如: Th ...
- paper:synthesizable finit state machine design techniques using the new systemverilog 3.0 enhancements之onehot coding styles(index-parameter style with registered outputs)
case语句中,对于state/next 矢量仅仅做了1-bit比较. parameter 值不是表示FSM的状态编码,而是表示state/next变量的索引.
- JAVA基础篇—多态
class ColaEmployee父类 package com.cola; public class ColaEmployee { private String name; private int ...
- Divisibility by 25 CodeForces - 988E
You are given an integer nn from 11 to 10181018 without leading zeroes. In one move you can swap any ...
- npm 安装express npm ERR! code UNABLE_TO_VERIFY_LEAF_SIGNATURE
npm安装总是报错 报错信息: 解决方案: 在命令行输入: npm config set strict-ssl false 设置之后即可安装软件:
- POJ 3241 曼哈顿距离最小生成树 Object Clustering
先上几个资料: 百度文库有详细的分析和证明 cxlove的博客 TopCoder Algorithm Tutorials #include <cstdio> #include <cs ...
- html-body相关标签
一 字体标签 字体标签包含:h1~h6.<font>.<u>.<b>.<strong><em>.<sup>.<sub& ...