openresty http


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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM