[Groonga-commit] droonga/express-droonga at 47ffa6a [master] Convert "/" in the path to "." for message types

Back to archive index

YUKI Hiroshi null+****@clear*****
Wed Jun 25 18:25:41 JST 2014


YUKI Hiroshi	2014-06-25 18:25:41 +0900 (Wed, 25 Jun 2014)

  New Revision: 47ffa6aae2fe16c15e38c027f99434c962bb6194
  https://github.com/droonga/express-droonga/commit/47ffa6aae2fe16c15e38c027f99434c962bb6194

  Message:
    Convert "/" in the path to "." for message types

  Modified files:
    lib/adapter/api/droonga.js

  Modified: lib/adapter/api/droonga.js (+9 -2)
===================================================================
--- lib/adapter/api/droonga.js    2014-06-25 18:23:22 +0900 (de0a93c)
+++ lib/adapter/api/droonga.js    2014-06-25 18:25:41 +0900 (bce2950)
@@ -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);
@@ -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;
-------------- next part --------------
HTML����������������������������...
Télécharger 



More information about the Groonga-commit mailing list
Back to archive index