[Groonga-commit] droonga/express-droonga at b84c091 [master] Support authorization by the framework

Back to archive index

YUKI Hiroshi null+****@clear*****
Thu Jan 9 20:44:47 JST 2014


YUKI Hiroshi	2014-01-09 20:44:47 +0900 (Thu, 09 Jan 2014)

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

  Message:
    Support authorization by the framework

  Modified files:
    lib/adapter/command.js
    lib/adapter/http.js

  Modified: lib/adapter/command.js (+3 -0)
===================================================================
--- lib/adapter/command.js    2014-01-09 17:03:48 +0900 (1e63bc5)
+++ lib/adapter/command.js    2014-01-09 20:44:47 +0900 (fca3878)
@@ -26,6 +26,9 @@ Command.extend = function(targetClass) {
     },
     set: function(name) { return this._name = name; }
   });
+  Object.defineProperty(targetClass.prototype, 'authorize', {
+    get: function() { return this._options.authorize; }
+  });
   targetClass.isInstance = function(modelInstance) {
     return (
       modelInstance &&

  Modified: lib/adapter/http.js (+12 -0)
===================================================================
--- lib/adapter/http.js    2014-01-09 17:03:48 +0900 (fffd97b)
+++ lib/adapter/http.js    2014-01-09 20:44:47 +0900 (85d9171)
@@ -35,6 +35,7 @@ function createRequestResponseHandler(params) {
         }
       }
 
+    var processRequest = function(request, response) {
     var wrappedConnection = new wrapper.DroongaProtocolConnectionWrapper(connection, callback, options);
     if (definition.onRequest) {
       try {
@@ -46,6 +47,11 @@ function createRequestResponseHandler(params) {
     } else {
       wrappedConnection.emit(commandName, request.query);
     }
+    }
+    if (typeof definition.authorize == 'function')
+      definition.authorize(processRequest, request, response);
+    else
+      processRequest();
   });
 }
 exports.createRequestResponseHandler = createRequestResponseHandler;
@@ -63,6 +69,7 @@ function createGenericHandler(params) {
       dataset: definition.dataset,
       timeout: definition.timeout || null
     };
+    var processRequest = function(request, response) {
     var wrappedConnection = new wrapper.DroongaProtocolConnectionWrapper(connection, options);
     try {
       definition.onHandle(request, response, wrappedConnection);
@@ -70,6 +77,11 @@ function createGenericHandler(params) {
       wrappedConnection.destroy();
       response.jsonp(error, 500);
     }
+    }
+    if (typeof definition.authorize == 'function')
+      definition.authorize(processRequest, request, response);
+    else
+      processRequest();
   });
 }
 exports.createGenericHandler = createGenericHandler;
-------------- next part --------------
HTML����������������������������...
Download 



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