[HTTPS] REST-love -> Crossplatform Async HTTPS Request
Posted: Fri Jul 10, 2020 3:37 pm
Hello guys, I made a mega wrapper for HTTPS requests, tested on Linux, Windows, Android and Web(Love.js)
Those requests are async (and could be made sync if that is your choice)
The wrapper is REALLY easy to use and there is no adaptation is required between those platform (Except web where you need to include a
And that's all
For using it, just
Current supported REST methods:
Module-Loader
You can easily other fully-pledged libraries into your project without adapting anything:
If one of those libraries call its own "require", you won't need to adapt anything, the start path for require will be the libpath
In this lib you can still find:
Async(Coroutine)Loader + LoadBar
With that, you can pass your own load function, it will be executed on the coroutine, it is a singleton
LoadBar is a simple bar that you can pass your own backFrame and frontFrame and render it(Doesn't use stencil yet), for using it, is very simple, and if not texture is provided, it uses a default rect for loading(nice for testing):
$ will be replaced by the current load percentage (current[0-100]%) format
Then, you just need to call in love.update
And that's all folks, if you wish to contribute, feel free as AsyncLoader and LoadBar is still wip
REST-love
Those requests are async (and could be made sync if that is your choice)
The wrapper is REALLY easy to use and there is no adaptation is required between those platform (Except web where you need to include a
Code: Select all
<script src="consolewrapper.js"></script>
For using it, just
Code: Select all
require "REST"
function love.load()
-- URL REQUEST-HEADER(TABLE FORMAT) ONLOAD
REST.get("https://example.com", nil, function(data)print(data);end)
end
function love.update(dt)
REST.retrieve(dt)
end
- GET
- POST
- PUT
- DELETE
- HEAD
- PATCH
Module-Loader
You can easily other fully-pledged libraries into your project without adapting anything:
Code: Select all
require "module-loader"
-- LIBPATH FILE
requireFromLib("js", "js")
requireFromLib("luajit-request", "luajit-request")
In this lib you can still find:
Async(Coroutine)Loader + LoadBar
With that, you can pass your own load function, it will be executed on the coroutine, it is a singleton
LoadBar is a simple bar that you can pass your own backFrame and frontFrame and render it(Doesn't use stencil yet), for using it, is very simple, and if not texture is provided, it uses a default rect for loading(nice for testing):
Code: Select all
require "loadbar"
loadBarInstance = LoadBar:new(width, height, frontTexture, backTexture)
imgs = {}
loadBarInstance.addContentToLoad(function()
imgs["myImg"] = love.graphics.newImage("myImg.png")
end, nil, "Loading myImg: $")
Then, you just need to call in love.update
Code: Select all
loadBarInstance:update(dt)
REST-love