The HTTP module is very bare bones. You can do single HTTP requests (GET, POST etc) with the ability to set headers, POST data and timeout and you get a callback with the response. Nothing more.
You can do multiple HTTP requests at the same time.
You have to write your own retry functionality.
You have to implement your own exponential back-off algorithm.
When you say “disconnected mode” do you then mean a way to detect network state or do you mean some kind of HTTP request caching for when the user is disconnected?
There are several Promise implementations in Lua (one example: https://github.com/zserge/lua-promises). We have our own implementation here at King as well. You can also use coroutines to get a synchronous code flow out of multiple asynchronous calls. Quick and dirty example:
local function get(url, headers)
local co = coroutine.running()
assert(co, "You must wrap this in a coroutine")
http.request(url, "GET", function(self, id, response)
coroutine.resume(co, response)
end, headers or {})
return coroutine.yield()
end
local function do_many_http_calls_one_after_the_other()
local response1 = get("http://www.acme.com/my/cool/api/endpoint1")
-- do stuff with the response
local response2 = get("http://www.acme.com/my/cool/api/endpoint2")
-- do more stuff
end
coroutine.wrap(do_many_http_calls_one_after_the_other)()