All Projects → antonheryanto → Lua Resty Post

antonheryanto / Lua Resty Post

HTTP post utility for openresty

Programming Languages

lua
6591 projects

Projects that are alternatives of or similar to Lua Resty Post

Lua Resty Route
URL Routing Library for OpenResty Supporting Pluggable Matching Engines
Stars: ✭ 88 (+193.33%)
Mutual labels:  openresty, luajit, nginx
Luajit.io
luajit io framework
Stars: ✭ 277 (+823.33%)
Mutual labels:  openresty, luajit, nginx
Apioak
Full Lifecycle Management API Gateway.
Stars: ✭ 335 (+1016.67%)
Mutual labels:  openresty, luajit, nginx
Lua Resty Http
Lua HTTP client cosocket driver for OpenResty / ngx_lua.
Stars: ✭ 1,647 (+5390%)
Mutual labels:  openresty, luajit, nginx
Motan Openresty
A cross-language RPC framework for rapid development of high performance distributed services based on OpenResty.
Stars: ✭ 117 (+290%)
Mutual labels:  openresty, luajit, nginx
Lua Resty Repl
Interactive console (REPL) for Openresty and luajit code
Stars: ✭ 165 (+450%)
Mutual labels:  openresty, luajit, nginx
Api Umbrella
Open source API management platform
Stars: ✭ 1,735 (+5683.33%)
Mutual labels:  openresty, luajit, nginx
Lua Resty Redis Connector
Connection utilities for lua-resty-redis
Stars: ✭ 186 (+520%)
Mutual labels:  openresty, luajit, nginx
Nano Nginx
Nano container with nginx preconfigured as reverse proxy
Stars: ✭ 15 (-50%)
Mutual labels:  luajit, nginx
Docker Nginx Auto Ssl
Docker image for automatic generation of SSL certs using Let's encrypt and Open Resty
Stars: ✭ 282 (+840%)
Mutual labels:  openresty, nginx
Kong
🦍 The Cloud-Native API Gateway
Stars: ✭ 30,838 (+102693.33%)
Mutual labels:  luajit, nginx
Nginx Openresty Windows
nginx for windows with openresty
Stars: ✭ 404 (+1246.67%)
Mutual labels:  openresty, nginx
Lua Resty Mlcache
Layered caching library for OpenResty
Stars: ✭ 274 (+813.33%)
Mutual labels:  openresty, luajit
lua-resty-jump-consistent-hash
consistent hash for openresty
Stars: ✭ 24 (-20%)
Mutual labels:  luajit, openresty
Proxygateway
Proxy Gateway基于openresty(nginx lua module)开发,可以作为接口网关(api gateway)使用,整合业务模块接口,微服务治理聚合,通过web配置界面,能够轻松进行代理配置管理,支持负载均衡,服务器状态检测等
Stars: ✭ 335 (+1016.67%)
Mutual labels:  openresty, nginx
Ledge
An RFC compliant and ESI capable HTTP cache for Nginx / OpenResty, backed by Redis
Stars: ✭ 412 (+1273.33%)
Mutual labels:  openresty, luajit
lua-resty-maxminddb
A Lua library for reading MaxMind's Geolocation database
Stars: ✭ 72 (+140%)
Mutual labels:  luajit, openresty
Kong Docs Cn
微服务 Api 网关 Kong 最新文档中文版
Stars: ✭ 371 (+1136.67%)
Mutual labels:  openresty, nginx
Apisix
The Cloud-Native API Gateway
Stars: ✭ 7,920 (+26300%)
Mutual labels:  luajit, nginx
Iptv
一键安装管理 FFmpeg / nginx / openresty / xray / v2ray / armbian / proxmox / cloudflare partner,workers / ibm cloud foundry 脚本
Stars: ✭ 481 (+1503.33%)
Mutual labels:  openresty, nginx

lua-resty-post

Openresty utility for HTTP post

Table of Contents

Status

This library beta tested and used in production.

Description

This library processed HTTP using lua-resty-upload which very fast and low memory used, it handles multiple type of HTTP POST and converted into lua table:

Back to TOC

Installation

  • Download or clone this repo
  • copy or link to openresty/lualib/resty/ or to any your lua_package_path

Back to TOC

How to use

local resty_post = require 'resty.post'
local post = resty_post:new()
local m = post:read()
-- return table with all form value and file

Back to TOC

File Upload

  • Support multiple file upload
  • Files info are stored in files property using field name as key
 { 
  files = {
   file1 = { -- input name
    name = "a.txt",
    type = "text/plain",
    size = 10240,
    tmp_name = 1454551131.5459
   },
   file2 = {
    name = "b.png",
    type = "image/png",
    size = 20480,
    tmp_name = 1454553275.6401
   }
 }
  • Define path for files upload or default to logs directory (follow ngx.config.prefix)
  • Default file will be saved to tmp name (require moving action to destination)
local resty_post = require "resty.post"
local post = resty_post:new({
 path = "/my/path",           -- path upload file will be saved
 chunk_size = 10240,          -- default 8192
 no_tmp = true,               -- if set original name will uses or generate random name
 name = function(name, field) -- overide name with user defined function
  return name.."_"..field 
 end
})
post:read()

Array Input

Support multiple input of similar name

It is useful for thing like HTML input checkboxes or select in multiple mode

<input type="checkbox" name="check_multi" value="1">
<input type="checkbox" name="check_multi" value="2">
<select name="select_multi" multiple>
 <option value="">Please select</option>
 <option value="1">One</option>
 <option value="2">Two</option>
</select>

converted into

{
 check_multi = { 1, 2 },
 select_multi = { 1, 2 } 
}

When checked one similar with ngx.req.get_post_args

{
 check_multi = 2,
 select_multi = 1
}

Support array input with name

This is like supporting input which mimic class and property, which can be uses to handle dynamic input support PHP style (dynamic language) and ASP.NET MVC binding style (static language which uses class)

<div class="name-index">
 <input name="name[1]" value="Foo">
 <input name="name[0]" value="Bar">
</div>
<div class="user-single">
 <input name="user.title" value="Mr.">
 <input name="user[name]" value="Foo Bar">
</div>
<div class="user-static">
 <input name="users[0].title" value="Mr.">
 <input name="users[0].name" value="John Do">
</div>
<div class="user-dynamic">
 <input name="users[0][title]" value="Ms.">
 <input name="users[0][name]" value="Jane Do">
</div>

converted into

{
 name = {
  "Bar",
  "Foo"
 },
 user = {
  title = "Mr.",
  name = "Foo Bar"
 },
 users = {
  {
   title = "Mr.",
   name = "John Do"
  },
  {
   title = "Ms.",
   name = "Jane Do"
  }
 }
}

Back to TOC

Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2015, by Anton Heryanto Hasan.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Back to TOC

See Also

Back to TOC

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].