mirror of
https://github.com/Doodle3D/doodle3d-firmware.git
synced 2024-11-16 10:47:55 +01:00
f988c13dfa
* change API access control to use function name suffixes * implement settings interface with baseline configuration * make AP properties configurable * AP SSID can now contain partial MAC address * update more quotation style and documentation * remove captive directory change from network mode switcher.
46 lines
1.6 KiB
Lua
46 lines
1.6 KiB
Lua
local l = require("util.logger")
|
|
local ResponseClass = require("rest.response")
|
|
|
|
local M = {
|
|
isApi = true
|
|
}
|
|
|
|
|
|
function M._global(request, response)
|
|
local ba = request:getBlankArgument()
|
|
|
|
response:setSuccess("REST test API - default function called with blank argument: '" .. (ba or "<nil>") .. "'")
|
|
if ba ~= nil then response:addData("blank_argument", ba) end
|
|
end
|
|
|
|
function M.success(request, response)
|
|
response:setSuccess("this successful response has been generated on purpose")
|
|
response:addData("url", "http://xkcd.com/349/")
|
|
end
|
|
|
|
function M.fail(request, response)
|
|
response:setFail("this failure has been generated on purpose")
|
|
response:addData("url", "http://xkcd.com/336/")
|
|
end
|
|
|
|
function M.error(request, response)
|
|
response:setError("this error has been generated on purpose")
|
|
response:addData("url", "http://xkcd.com/1024/")
|
|
end
|
|
|
|
|
|
function M.read(request, response) response:setSuccess("this endpoint can only be accessed through GET request") end
|
|
function M.write_POST(request, response) response:setSuccess("this endpoint can only be accessed through POST request") end
|
|
function M.readwrite(request, response) response:setSuccess("this endpoint can be accessed both through GET and POST request") end
|
|
function M.readwrite2(request, response) response:setSuccess("this endpoint can be accessed both through GET and POST request") end
|
|
|
|
|
|
function M.echo(request, response)
|
|
response:setSuccess("request echo")
|
|
response:addData("request_data", request:getAll())
|
|
response:addData("blank_argument", request:getBlankArgument())
|
|
response:addData("path_data", request:getPathData())
|
|
end
|
|
|
|
return M
|