2013-07-08 13:34:27 +02:00
|
|
|
local l = require("logger")
|
|
|
|
local ResponseClass = require("rest.response")
|
|
|
|
|
|
|
|
local M = {}
|
|
|
|
|
|
|
|
M.isApi = true
|
|
|
|
|
2013-07-10 00:32:43 +02:00
|
|
|
function M._global(request, response)
|
|
|
|
local ba = request:getBlankArgument()
|
2013-07-08 16:53:45 +02:00
|
|
|
|
2013-07-10 00:32:43 +02:00
|
|
|
response:setSuccess("REST test API - default function called with blank argument: '" .. (ba or "<nil>") .. "'")
|
|
|
|
if ba ~= nil then response:addData("blank_argument", ba) end
|
2013-07-08 13:34:27 +02:00
|
|
|
end
|
|
|
|
|
2013-07-10 00:32:43 +02:00
|
|
|
function M.success(request, response)
|
|
|
|
response:setSuccess("this successful response has been generated on purpose")
|
|
|
|
response:addData("url", "http://xkcd.com/349/")
|
2013-07-08 13:34:27 +02:00
|
|
|
end
|
|
|
|
|
2013-07-10 00:32:43 +02:00
|
|
|
function M.fail(request, response)
|
|
|
|
response:setFail("this failure has been generated on purpose")
|
|
|
|
response:addData("url", "http://xkcd.com/336/")
|
2013-07-08 19:02:20 +02:00
|
|
|
end
|
|
|
|
|
2013-07-10 00:32:43 +02:00
|
|
|
function M.error(request, response)
|
|
|
|
response:setError("this error has been generated on purpose")
|
|
|
|
response:addData("url", "http://xkcd.com/1024/")
|
2013-07-08 13:34:27 +02:00
|
|
|
end
|
|
|
|
|
2013-07-10 00:32:43 +02:00
|
|
|
function M.echo(request, response)
|
|
|
|
response:setSuccess("request echo")
|
2013-07-11 10:30:59 +02:00
|
|
|
response:addData("request_data", request:getAll())
|
|
|
|
response:addData("blank_argument", request:getBlankArgument())
|
|
|
|
response:addData("path_data", request:getPathData())
|
2013-07-08 13:34:27 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return M
|