Reorganize and clean up plugin

This commit is contained in:
Lucien Greathouse
2019-10-01 18:23:29 -07:00
parent bdd9c58cae
commit f9a5fee364
16 changed files with 125 additions and 113 deletions

34
plugin/http/Response.lua Normal file
View File

@@ -0,0 +1,34 @@
local HttpService = game:GetService("HttpService")
local stringTemplate = [[
Http.Response {
code: %d
body: %s
}]]
local Response = {}
Response.__index = Response
function Response:__tostring()
return stringTemplate:format(self.code, self.body)
end
function Response.fromRobloxResponse(response)
local self = {
body = response.Body,
code = response.StatusCode,
headers = response.Headers,
}
return setmetatable(self, Response)
end
function Response:isSuccess()
return self.code >= 200 and self.code < 300
end
function Response:json()
return HttpService:JSONDecode(self.body)
end
return Response