YUKI Hiroshi
null+****@clear*****
Fri Oct 4 18:15:32 JST 2013
YUKI Hiroshi 2013-10-04 18:15:32 +0900 (Fri, 04 Oct 2013) New Revision: 75322e60492ebbe706de8910514c669e391c9003 https://github.com/droonga/express-droonga/commit/75322e60492ebbe706de8910514c669e391c9003 Message: Add droonga http API to process any droonga message (for testing) Added files: lib/adapter/api/droonga.js Modified files: lib/adapter/http.js Added: lib/adapter/api/droonga.js (+22 -0) 100644 =================================================================== --- /dev/null +++ lib/adapter/api/droonga.js 2013-10-04 18:15:32 +0900 (03fc8c2) @@ -0,0 +1,22 @@ +var command = require('../command'); +var requestBuilders = require('./rest-request-builder'); + +module.exports = { + // XXX dangerous! this must be disabled on public services. + 'droonga': new command.HTTPCommand({ + method: 'POST', + path: '/droonga/:messageType', + onRequest: function(request, connection) { + var messageType = request.params.messageType; + + var body = request.body; + it (typeof body == 'string') + body = JSON.parse(body); + + body.timeout = body.timeout || 1000; + body.type = body.type || 'droonga-' + messageType; + + connection.emit(messageType, body); + } + }) +}; Modified: lib/adapter/http.js (+2 -1) =================================================================== --- lib/adapter/http.js 2013-09-10 17:31:45 +0900 (0b434dd) +++ lib/adapter/http.js 2013-10-04 18:15:32 +0900 (94d243d) @@ -3,6 +3,7 @@ var debug = require('../debug'); var command = require('./command'); var wrapper = require('./wrapper'); var restAPI = require('./api/rest'); +var droongaAPI = require('./api/droonga'); var groongaAPI = require('./api/groonga'); function createHandler(params) { @@ -68,7 +69,7 @@ exports.register = function(application, params) { var prefix = params.prefix || ''; prefix = prefix.replace(/\/$/, ''); - var commandSets = [restAPI, groongaAPI].concat(params.plugins || []); + var commandSets = [restAPI, droongaAPI, groongaAPI].concat(params.plugins || []); var unifiedCommandSet = {}; commandSets.forEach(function(commandSet) { Object.keys(commandSet).forEach(function(commandName) { -------------- next part -------------- HTML����������������������������...Download