YUKI Hiroshi
null+****@clear*****
Wed Feb 6 16:24:22 JST 2013
YUKI Hiroshi 2013-02-06 16:24:22 +0900 (Wed, 06 Feb 2013) New Revision: c187006135182206011d99c013671474f0d88e05 https://github.com/groonga/express-kotoumi/commit/c187006135182206011d99c013671474f0d88e05 Log: Detect REST command definitions by "path" instead of "method", because "method" can be omitted Modified files: lib/frontend/rest-adaptor.js Modified: lib/frontend/rest-adaptor.js (+5 -6) =================================================================== --- lib/frontend/rest-adaptor.js 2013-02-06 13:16:41 +0900 (a44eae8) +++ lib/frontend/rest-adaptor.js 2013-02-06 16:24:22 +0900 (741e3f1) @@ -36,14 +36,13 @@ function createHandler(params) { exports.createHandler = createHandler; function getRegisterationMethod(method) { + method = method || 'GET'; switch (method.toUpperCase()) { - case 'GET': return 'get'; case 'PUT': return 'put'; case 'POST': return 'post'; case 'DELETE': return 'del'; - default: - throw new Error(method + ' is unsppported HTTP method!'); - } + default: return 'get'; + } } exports.getRegisterationMethod = getRegisterationMethod; @@ -64,7 +63,7 @@ exports.register = function(application, params) { Object.keys(commandSet).forEach(function(command) { var definition = commandSet[command]; - if (!definition.method) // ignore non-REST command + if (!definition.path) // ignore non-REST command return; unifiedCommandSet[command] = definition; }); @@ -73,7 +72,7 @@ exports.register = function(application, params) { var registeredCommands = []; Object.keys(unifiedCommandSet).forEach(function(command) { var definition = unifiedCommandSet[command]; - if (!definition.method) // ignore not a command definition + if (!definition.path) // ignore not a command definition return; var method = getRegisterationMethod(definition.method); var handler = createHandler({ -------------- next part -------------- HTML����������������������������...Download