Simple HTTP
下面是代码:
local http = require("lapis.nginx.http")
local app = lapis.Application()
app:get("/", function(self)
-- a simple GET request
local body, status_code, headers = http.simple("http://leafo.net")
-- a post request, data table is form encoded and content-type is set to
-- application/x-www-form-urlencoded
http.simple("http://leafo.net/", {
name = "leafo"
})
-- manual invocation of the above request
http.simple({
url = "http://leafo.net",
method = "POST",
headers = {
["content-type"] = "application/x-www-form-urlencoded"
},
body = {
name = "leafo"
}
})
end)