diff --git a/actions/create_document.lua b/actions/create_document.lua index fd576da..e16202a 100644 --- a/actions/create_document.lua +++ b/actions/create_document.lua @@ -28,10 +28,12 @@ end contentdb.write_file (store, id or document_uuid, fields, request.body.body) +local redirect = "
" + return { headers = { - ["content-type"] = "application/json", + ["content-type"] = "text/html", ["X-Request-ID"] = request.uuid }, - body = json.from_table(params) + body = redirect } diff --git a/actions/list_documents.lua b/actions/list_documents.lua index c9636f4..48c2883 100644 --- a/actions/list_documents.lua +++ b/actions/list_documents.lua @@ -3,22 +3,32 @@ priority = 1 input_parameters = ["request"] -- GET /[type]/[uuid] + local model_name = request.path_segments[1] local uuids = {} -contentdb.walk_documents(nil, function (file_uuid, header, body) - if fields.model ~= model_name then return end - -- Filter the documents using the query params - for k, v in pairs(request.query) do - if header[k] ~= v then - -- Don't add this document to the list - return + +contentdb.walk_documents(nil, + function (file_uuid, fields, body, store) + if fields.model ~= model_name then return end + + -- Filter the documents using the query params + for k, v in pairs(request.query) do + if fields[k] ~= v then + -- Don't add this document to the list + return + end end + + table.insert(uuids, { + name = fields.name or fields.title, + uuid = file_uuid, + store = store + }) end +) - table.insert(uuids, file_uuid) -end) return { headers = { diff --git a/actions/list_subdocuments.lua b/actions/list_subdocuments.lua index 031bf7d..7b5347e 100644 --- a/actions/list_subdocuments.lua +++ b/actions/list_subdocuments.lua @@ -18,12 +18,11 @@ contentdb.walk_documents(nil, function (doc_id, fields, body) end) - if #uuids == 0 then uuids = nil end return { headers = { - ["content-type"] = "text/html", + ["content-type"] = "application/json", }, body = json.from_table({ base_model = base_model,