YUKI Hiroshi
null+****@clear*****
Thu Feb 7 19:27:17 JST 2013
YUKI Hiroshi 2013-02-07 19:27:17 +0900 (Thu, 07 Feb 2013) New Revision: 50a43ddd6e1ea87059df26abdb50fa7d447bbc99 https://github.com/groonga/express-kotoumi/commit/50a43ddd6e1ea87059df26abdb50fa7d447bbc99 Log: REST commands also receive command name and they can replace event name Modified files: lib/frontend/default-commands/rest.js lib/frontend/rest-adaptor.js Modified: lib/frontend/default-commands/rest.js (+3 -1) =================================================================== --- lib/frontend/default-commands/rest.js 2013-02-07 19:01:35 +0900 (09ba9ae) +++ lib/frontend/default-commands/rest.js 2013-02-07 19:27:17 +0900 (30a003e) @@ -8,7 +8,9 @@ module.exports = { // }), 'search': new model.REST({ path: '/tables/:tableName', - toBackend: requestBuilders.search + toBackend: function(event, request) { + return [event, requestBuilders.search(request)]; + } }) //, // 'createtable': new model.REST({ // method: 'PUT', Modified: lib/frontend/rest-adaptor.js (+6 -4) =================================================================== --- lib/frontend/rest-adaptor.js 2013-02-07 19:01:35 +0900 (a486382) +++ lib/frontend/rest-adaptor.js 2013-02-07 19:27:17 +0900 (6a4ae3e) @@ -11,11 +11,13 @@ function createHandler(params) { throw new Error('no filter for the backend: ' + commandName); return (function(request, response) { - var message = definition.toBackend(request); + var result = definition.toBackend(commandName, request); + var messageType = result[0]; + var body = result[1]; var timeout = message.timeout || null; connection.emitMessage( - commandName, - message, + messageType, + body, function(error, responseMessage) { if (error) { var body = responseMessage && responseMessage.body || null; @@ -24,7 +26,7 @@ function createHandler(params) { } else { var body = responseMessage.body; if (definition.toClient) - body = definition.toClient(body); + body = definition.toClient(commandName, body); response.contentType('application/json'); response.send(body, 200); } -------------- next part -------------- HTML����������������������������...Download