当前位置:首页 > Web开发 > 正文

下载方式: wget?https://raw.githubusercontent.com/pintsized/lua-

2024-03-31 Web开发

标签:

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", } })

参考:

GitHub - ledgetech/lua-resty-http: Lua HTTP client cosocket driver for OpenResty / ngx_lua.

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31955.html