mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 17:17:33 +00:00
http function are now shared
This commit is contained in:
parent
9b2af71970
commit
4b3f37a953
|
@ -2,18 +2,14 @@
|
|||
// HTTP
|
||||
//
|
||||
|
||||
|
||||
// Variables
|
||||
gmInte.api = 'https://api.gmod-integration.com/'
|
||||
gmInte.defParams = "&id=" .. gmInte.config.id .. "&token=" .. gmInte.config.token .. "&version=" .. gmInte.version
|
||||
gmInte.defParams = "&version=" .. gmInte.version
|
||||
|
||||
// Functions
|
||||
function gmInte.isCodeValid(code)
|
||||
if code == 200 then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
// if first number is 2
|
||||
return string.sub(code, 1, 1) == "2"
|
||||
end
|
||||
|
||||
function gmInte.httpError(error)
|
||||
|
@ -26,7 +22,11 @@ function gmInte.ulrGenerate(endpoint, parameters)
|
|||
for k, v in pairs(parameters) do
|
||||
params = params .. "&" .. k .. "=" .. v
|
||||
end
|
||||
return gmInte.api .. endpoint .. "?" .. params .. gmInte.defParams
|
||||
if SERVER then
|
||||
return gmInte.api .. endpoint .. "?" .. params .. gmInte.defParams .. "&id=" .. gmInte.config.id .. "&token=" .. gmInte.config.token
|
||||
else
|
||||
return gmInte.api .. endpoint .. "?" .. params .. gmInte.defParams
|
||||
end
|
||||
end
|
||||
|
||||
function gmInte.fetch(endpoint, parameters, onSuccess)
|
Loading…
Reference in New Issue
Block a user