http function are now shared

This commit is contained in:
Linventif 2023-08-13 10:00:25 +00:00
parent 9b2af71970
commit 4b3f37a953

View File

@ -2,18 +2,14 @@
// HTTP // HTTP
// //
// Variables // Variables
gmInte.api = 'https://api.gmod-integration.com/' 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 // Functions
function gmInte.isCodeValid(code) function gmInte.isCodeValid(code)
if code == 200 then // if first number is 2
return true return string.sub(code, 1, 1) == "2"
else
return false
end
end end
function gmInte.httpError(error) function gmInte.httpError(error)
@ -26,7 +22,11 @@ function gmInte.ulrGenerate(endpoint, parameters)
for k, v in pairs(parameters) do for k, v in pairs(parameters) do
params = params .. "&" .. k .. "=" .. v params = params .. "&" .. k .. "=" .. v
end 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 end
function gmInte.fetch(endpoint, parameters, onSuccess) function gmInte.fetch(endpoint, parameters, onSuccess)