openresty http

taoqilin 2020-01-09

openresty http

  • openresty默认没有提供http客户端,需要第三方提供插件。
  • 下载方式:
wget?https://raw.githubusercontent.com/pintsized/lua-resty-http/master/lib/resty/http_headers.lua??
wget?https://raw.githubusercontent.com/pintsized/lua-resty-http/master/lib/resty/http.lua??
  • 将文件放在 /openresty/lualib/resty/目录下即可
  • 使用方式
local res, err = httpc:request_uri(uri, {  
    method = "POST/GET",  ---请求方式
    query = str,  ---get方式传参数
    body = str,     ---post方式传参数
    path = "url" ----路径
    headers = {  ---header参数
        ["Content-Type"] = "application/json",  
    }  
})

相关推荐