0
0
mirror of https://github.com/Doodle3D/doodle3d-firmware.git synced 2024-11-16 18:47:57 +01:00
doodle3d-firmware/src/rest/api/api_test.lua

47 lines
1022 B
Lua
Raw Normal View History

local l = require("logger")
local ResponseClass = require("rest.response")
local M = {}
M.isApi = true
function M._global(d)
local r = ResponseClass.new(d)
local ba = d:getBlankArgument()
r:setSuccess("REST test API - default function called with blank argument: '" .. (ba or "<nil>") .. "'")
if ba ~= nil then r:addData("blank_argument", ba) end
return r
end
function M.success(d)
local r = ResponseClass.new(d)
r:setSuccess("this successful response has been generated on purpose")
r:addData("url", "http://xkcd.com/349/")
return r
end
function M.fail(d)
local r = ResponseClass.new(d)
r:setFail("this failure has been generated on purpose")
r:addData("url", "http://xkcd.com/336/")
return r
end
function M.error(d)
local r = ResponseClass.new(d)
r:setError("this error has been generated on purpose")
r:addData("url", "http://xkcd.com/1024/")
return r
end
function M.echo(d)
local r = ResponseClass.new(d)
r:setSuccess("request echo")
r:addData("request_data", d)
return r
end
return M