Navigation Menu

Skip to content

Commit

Permalink
groonga: Support ".json" optional suffix
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Apr 28, 2014
1 parent 9a2d309 commit 9b41a40
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions lib/adapter/api/groonga.js
Expand Up @@ -145,19 +145,32 @@ Loader.prototype._sendResponse = function _sendResponse(body) {
this._response.jsonp(groongaResponse, httpStatusCode);
};

function handleHTTPRequest(request, connection) {
connection.emit(request.params.commandName, request.query);
}

function handleLoadHTTPRequest(request, connection) {
var loader = new Loader(request, response, connection, this.logger);
loader.run();
}

module.exports = {
'groonga': new command.HTTPRequestResponse({
path: '/d/:commandName',
onRequest: function(request, connection) {
connection.emit(request.params.commandName, request.query);
}
onRequest: handleHTTPRequest
}),
'groonga': new command.HTTPRequestResponse({
path: '/d/:commandName.json',
onRequest: handleHTTPRequest
}),
'groonga-load': new command.HTTPRequestResponse({
method: 'POST',
path: '/d/load',
onRequest: function(request, connection, response) {
var loader = new Loader(request, response, connection, this.logger);
loader.run();
}
onRequest: handleLoadHTTPRequest
}),
'groonga-load': new command.HTTPRequestResponse({
method: 'POST',
path: '/d/load.json',
onRequest: handleLoadHTTPRequest
})
};

0 comments on commit 9b41a40

Please sign in to comment.