mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-10-20 17:41:37 +00:00
Reorganize and clean up plugin
This commit is contained in:
parent
bdd9c58cae
commit
f9a5fee364
16 changed files with 125 additions and 113 deletions
34
plugin/http/Response.lua
Normal file
34
plugin/http/Response.lua
Normal 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
|
||||
Loading…
Add table
Add a link
Reference in a new issue