Navigation Menu

Skip to content

Commit

Permalink
Convert "/" in the path to "." for message types
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jun 25, 2014
1 parent 63cd0ea commit 47ffa6a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lib/adapter/api/droonga.js
@@ -1,11 +1,18 @@
var command = require('../command');

function pathToMessageType(path) {
return path
.split('?')[0]
.replace(/\/$/, '')
.replace(/\//g, '.');
}

module.exports = {
'droonga-get': new command.HTTPRequestResponse({
method: 'GET',
path: /^\/droonga\/(.+)/,
onRequest: function(request, connection) {
var messageType = request.params[0];
var messageType = pathToMessageType(request.params[0]);
var body = {};
body.timeout = body.timeout || 1000;
connection.emit(messageType, body);
Expand All @@ -16,7 +23,7 @@ module.exports = {
method: 'POST',
path: /^\/droonga\/(.+)/,
onRequest: function(request, connection) {
var messageType = request.params[0];
var messageType = pathToMessageType(request.params[0]);
var body = '';
request.on('data', function(chunk) {
body += chunk;
Expand Down

0 comments on commit 47ffa6a

Please sign in to comment.