edit: hide body if not showable

This commit is contained in:
Linventif 2024-02-22 17:48:51 +01:00
parent 00880889bf
commit 0cb1caa020
No known key found for this signature in database
GPG Key ID: FAC0CA60F9AEEC24

View File

@ -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({