From e684968a599a04501c04470e92de7cecdbb714cd Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Fri, 18 Dec 2015 13:36:25 +0000 Subject: [PATCH] Add ability to request the doc as plain text, rather than a json object. This makes it much easier to stream-parse the document. --- .../Features/Documents/DocumentController.coffee | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/web/app/coffee/Features/Documents/DocumentController.coffee b/services/web/app/coffee/Features/Documents/DocumentController.coffee index 4ac575af58..8cae627ab6 100644 --- a/services/web/app/coffee/Features/Documents/DocumentController.coffee +++ b/services/web/app/coffee/Features/Documents/DocumentController.coffee @@ -6,15 +6,20 @@ module.exports = getDocument: (req, res, next = (error) ->) -> project_id = req.params.Project_id doc_id = req.params.doc_id + plain = req?.query?.plain == 'true' logger.log doc_id:doc_id, project_id:project_id, "receiving get document request from api (docupdater)" ProjectEntityHandler.getDoc project_id, doc_id, (error, lines, rev) -> if error? logger.err err:error, doc_id:doc_id, project_id:project_id, "error finding element for getDocument" return next(error) - res.type "json" - res.send JSON.stringify { - lines: lines - } + if plain + res.type "text/plain" + res.send lines.join('\n') + else + res.type "json" + res.send JSON.stringify { + lines: lines + } setDocument: (req, res, next = (error) ->) -> project_id = req.params.Project_id