There are a lot of good RESTful APIs out there that I would like to use on ROBLOX, but have to go through the pain of creating a backend server because they use Http methods such as PUT, DELETE, and I think a few others. I’m pretty sure this shouldn’t be too hard to implement, and would make life a lot easier.
I think it would be nice to just have a generic Http request capability, then the ability to pass the method type to that. Kinda like you would do with just about any other Http API.
Example:
local response = httpService:Send {
Method = "GET",
URL = "http://www.example.com",
Header = {}
-- etc.
}
Thank you for your highly detailed and informative post.[/quote]
I am looking to use services such as Google APIs for Data Storage, and other useful resources. Mainly Data Storage, however. I do have a PHP/MySQL setup that works, but I am worried it won’t last well under load (and to bump it up, it would cost a lot of extra money). Besides my reason, I don’t understand why ROBLOX doesn’t allow HttpService to support such features. It should have been included on release.
HttpService:RequestAsync{
method = "GET", -- Any HTTP method. Could also be an Enum.
url = "http://www.google.co.uk",
[body = "Hello, world!",] -- Optional. Only required for requests which need a body.
[cache = true] -- Optional. If false, the response will not be cached.
}
-- Or, if it /absolutely/ needed to be a method and not accept a table:
HttpService:RequestAsync(string url[, string method = "GET"[, string body = nil]]) -- Again, 'method' could be an Enum.
HttpService:RequestNoCacheAsync(string url[, string method = "GET"[, string body = nil]]) -- Instead of using a boolean argument for caching, I decided a new method would be better as it means that the body would not need to be supplied as 'nil' when sending a non-caching GET/bodiless request.
Another suggestion would be that HTTPService get XML encoding/decoding support too. Admittedly, XML isn’t as awesome as JSON but IIRC some web services only provide XML responses. XML (not simple XML - I mean stuff like RSS feeds) is a pain to parse/lex correctly using pure lua pattern matching. Plus, unless ROBLOX’s JSON parser implements JSON-LD, XML can use a schema to ‘typecheck’ data to ensure it is the correct format.