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 个阶段,按照执行顺序依次是 ...
随机推荐
- caffe parse_log.sh
画loss曲线需要用到此shell脚本 #!/bin/bash # Usage parse_log.sh caffe.log # It creates the following two text f ...
- python_98_面向对象_学校
class School(object):#以后都加object(基类) def __init__(self, name, addr): self.name = name self.addr = ad ...
- 线程的sleep方法
- UICollectionView实现无限轮播
#import "KGNewsController.h"#import "KGNewsCell.h"#import "KGNews.h"#i ...
- 【转】VxWorks信号量分析
Wind内核中有二进制信号量.计数信号量和互斥信号量三种类型,为了是运用程序具有可移植性,还提供了POSIX(可移植操作系统接口)信号量 .在VxWorks中,信号量是实现任务同步的主要手段,也是解决 ...
- Redis 和缓存技术
Redis 是什么?什么作用?优点和缺点? https://blog.csdn.net/weixin_42295141/article/details/81380633 Redis 的主要功能哨兵+复 ...
- 【数学 BSGS】bzoj2242: [SDOI2011]计算器
数论的板子集合…… Description 你被要求设计一个计算器完成以下三项任务: 1.给定y,z,p,计算Y^Z Mod P 的值: 2.给定y,z,p,计算满足xy≡ Z ( mod P )的最 ...
- 【wqs二分】HHHOJ#15. 赤
这个wqs二分并不熟练…… 题目描述 #15. 赤 题目分析 两维都用wqs二分,其他没有什么特殊之处. 重点在于,wqs二分还原最优解的时候,增量是强制给的k. #include<bits/s ...
- php进行文件的强制下载
浏览器下载文件,例如在浏览器中可以直接打开的文件(.gif /.txt等).在进行文件下载操作时,默认是通过浏览器直接打开,而不是下载保存文件.并且通过这种方法下载文件可以不暴漏下载文件所在的路径,可 ...
- http 基础与通讯原理
目录 http 基础与通讯原理 Internet 与中国 1990年10月 注册CN顶级域名 1993年3月2日 接入第一根专线 1994年4月20日 实现与互联网的全功能连接 1994年5月21日 ...