mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:07:34 +00:00
edit: hide body if not showable
This commit is contained in:
parent
00880889bf
commit
0cb1caa020
|
@ -24,6 +24,15 @@ local function getAPIURL(endpoint)
|
||||||
return url .. endpoint
|
return url .. endpoint
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function showableBody(endpoint)
|
||||||
|
// if start with /streams or /screenshots return false
|
||||||
|
if (string.sub(endpoint, 1, 8) == "/streams" || string.sub(endpoint, 1, 12) == "/screenshots") then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
function gmInte.http.requestAPI(params)
|
function gmInte.http.requestAPI(params)
|
||||||
local body = params.body || ""
|
local body = params.body || ""
|
||||||
local bodyLength = string.len(body)
|
local bodyLength = string.len(body)
|
||||||
|
@ -33,6 +42,7 @@ function gmInte.http.requestAPI(params)
|
||||||
local success = params.success || function() end
|
local success = params.success || function() end
|
||||||
local failed = params.failed || function(error) gmInte.logError(error.error || error) end
|
local failed = params.failed || function(error) gmInte.logError(error.error || error) end
|
||||||
local version = gmInte.config.version
|
local version = gmInte.config.version
|
||||||
|
local showableBody = showableBody(params.endpoint)
|
||||||
|
|
||||||
local headers = {
|
local headers = {
|
||||||
["Content-Type"] = "application/json",
|
["Content-Type"] = "application/json",
|
||||||
|
@ -45,7 +55,7 @@ function gmInte.http.requestAPI(params)
|
||||||
// Log
|
// Log
|
||||||
if (gmInte.config.devInstance) then gmInte.log("HTTP Using dev Instance", true) end
|
if (gmInte.config.devInstance) then gmInte.log("HTTP Using dev Instance", true) end
|
||||||
gmInte.log("HTTP Request: " .. method .. " " .. url, true)
|
gmInte.log("HTTP Request: " .. method .. " " .. url, true)
|
||||||
gmInte.log("HTTP Body: " .. body, true)
|
gmInte.log("HTTP Body: " .. (showableBody && body || "HIDDEN"), true)
|
||||||
|
|
||||||
// Send
|
// Send
|
||||||
HTTP({
|
HTTP({
|
||||||
|
|
Loading…
Reference in New Issue
Block a user