openresty http

openresty http

  • openresty default does not provide http client, you need third-party plug-ins.
  • Download:
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  
  • The files in the / openresty / lualib / resty / directory can
  • Use
local res, err = httpc:request_uri(uri, {  
    method = "POST/GET",  ---请求方式
    query = str,  ---get方式传参数
    body = str,     ---post方式传参数
    path = "url" ----路径
    headers = {  ---header参数
        ["Content-Type"] = "application/json",  
    }  
})

Guess you like

Origin www.cnblogs.com/frankltf/p/12171855.html