<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Lua on Cylon&#39;s Collection</title>
    <link>https://www.161616.top/tags/lua/</link>
    <description>Recent content in Lua on Cylon&#39;s Collection</description>
    <generator>Hugo -- 0.125.7</generator>
    <language>zh</language>
    <lastBuildDate>Mon, 01 Jan 0001 00:00:00 +0000</lastBuildDate>
    <atom:link href="https://www.161616.top/tags/lua/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>lua cjson使用</title>
      <link>https://www.161616.top/lua-cjson/</link>
      <pubDate>Wed, 02 Oct 2019 00:00:00 +0000</pubDate>
      <guid>https://www.161616.top/lua-cjson/</guid>
      <description>cjson下载
https://github.com/mpx/lua-cjson.git
下载解压后，编译需要根据自己的lua环境以及操作系统修改Makefile的一些配置，不然容易出错。 以下是Makefile中的一些配置。
c 1 2 3 4 5 6 7 8 LUA_VERSION = 5.2 TARGET = cjson.so PREFIX = /usr/local CJSON_LDFLAGS = -shared LUA_INCLUDE_DIR = $(PREFIX)/include LUA_CMODULE_DIR = $(PREFIX)/lib/lua/$(LUA_VERSION) LUA_MODULE_DIR = $(PREFIX)/share/lua/$(LUA_VERSION) LUA_BIN_DIR = $(PREFIX)/bin https://blog.gezhiqiang.com/2017/08/24/lua-cjson/
lua 1 2 3 4 5 6 7 8 9 10 11 12 13 local cjson = require(&amp;#34;cjson&amp;#34;) local obj = { id = 1, name = &amp;#34;zhangsan&amp;#34;, age = nil, is_male = false, hobby = {&amp;#34;zhangsan&amp;#34;,&amp;#34;lisi&amp;#34;,&amp;#34;wangwu&amp;#34;} } local str = cjson.</description>
    </item>
    <item>
      <title>lua nginx api</title>
      <link>https://www.161616.top/lua-nginx-api/</link>
      <pubDate>Wed, 02 Oct 2019 00:00:00 +0000</pubDate>
      <guid>https://www.161616.top/lua-nginx-api/</guid>
      <description>lua 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 location = /reqq { default_type text/plain; content_by_lua_block { ngx.req.read_body() local data = ngx.req.get_body_data() local args, err = ngx.req.get_uri_args() if not args then ngx.say(&amp;#39;post fail&amp;#39;) return end for key,v in pairs(args) do ngx.say(key,&amp;#34;::&amp;#34;,v,&amp;#34;--&amp;#34;) end ngx.say(data) } } ngx.exec 内部重定向 lua 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 location = /bb { default_type text/plain; content_by_lua_block{ ngx.</description>
    </item>
    <item>
      <title>lua nginx module</title>
      <link>https://www.161616.top/lua-nginx-module/</link>
      <pubDate>Wed, 02 Oct 2019 00:00:00 +0000</pubDate>
      <guid>https://www.161616.top/lua-nginx-module/</guid>
      <description>lua 1 2 3 4 5 6 7 8 9 10 package1 = {} package1.const = &amp;#34;测试常量&amp;#34; function package1.func1() io.write(&amp;#34;this is public func\n&amp;#34;) end return package1 req.lua
lua 1 2 3 require &amp;#34;package1&amp;#34; package1.func1() print(package1) text 1 2 3 lc@lc-virtual-machine:~/lua$ lua pack1.lua this is public func table: 0x5575766224a0 注意事项：
测试文件是和封装好的模块在同一个目录，否则引用时需要设置路径。
lua 1 2 3 4 5 6 7 package.path = &amp;#39;/home/lc/lua/1/package1.lua;&amp;#39;; require &amp;#34;package1&amp;#34; package1.func1() print(package1) 模块名称和文件名称必须相同</description>
    </item>
  </channel>
</rss>
