Skip to content

Instantly share code, notes, and snippets.

@creationix
Last active August 29, 2015 14:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save creationix/f87eb113a7ebad8ba186 to your computer and use it in GitHub Desktop.
Save creationix/f87eb113a7ebad8ba186 to your computer and use it in GitHub Desktop.
Build this sample with `lit make gist://creationix/f87eb113a7ebad8ba186`. No need to clone, simply install latest lit first.
-- Load some libraries
local uv = require('uv')
local request = require('coro-http').request
local jsonParse = require('json').parse
-- Run our logic in a coroutine for blocking coro-I/O
coroutine.wrap(function ()
-- Make an http request
local res, body = request("GET", "http://lit.luvit.io/packages/creationix")
-- Print the results
p(res)
p(jsonParse(body))
-- Stop the event loop
uv.stop()
end)()
-- Start the event loop
uv.run()
return {
name = "creationix/gist-test",
version = "0.0.0",
private = true,
dependencies = {
"luvit/require",
"luvit/pretty-print",
"luvit/json",
"creationix/coro-http"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment