null+****@clear*****
null+****@clear*****
2012年 6月 21日 (木) 16:00:36 JST
Yoji SHIDARA 2012-06-21 16:00:36 +0900 (Thu, 21 Jun 2012) New Revision: d85c6bebded8331ae3b4e1b722600ed7ab7f1b37 https://github.com/groonga/gcs/commit/d85c6bebded8331ae3b4e1b722600ed7ab7f1b37 Log: Mount html on / for requests without Action Added files: test/dashboard.test.js views/index.jade views/layout.jade Modified files: lib/api/2011-02-01/configuration.js lib/server.js package.json test/api-configuration.test.js Modified: lib/api/2011-02-01/configuration.js (+8 -8) =================================================================== --- lib/api/2011-02-01/configuration.js 2012-06-21 16:01:55 +0900 (6c84642) +++ lib/api/2011-02-01/configuration.js 2012-06-21 16:00:36 +0900 (bcf4702) @@ -140,11 +140,19 @@ handlers.DefineIndexField = function(database, request, response) { }); }; +function dashboardHandler(request, response) { + return response.render('index.jade'); +} exports.createHandler = function(database) { return function(request, response) { var message, body; + var action = request.query.Action || ''; + if (!action) { + return dashboardHandler(request, response); // GCS original behaviour + } + var version = request.query.Version; if (!version) { message = 'An input parameter "Version" that is mandatory for ' + @@ -162,14 +170,6 @@ exports.createHandler = function(database) { return response.send(body, 400); } - var action = request.query.Action || ''; - if (!action) { - message = 'The request is missing an action or operation parameter.'; - body = createCommonErrorResponse('MissingAction', message); - response.contentType('application/xml'); - return response.send(body, 400); - } - if (!(action in handlers)) { message = 'The action ' + action + ' is not valid for this web service.'; body = createCommonErrorResponse('InvalidAction', message); Modified: lib/server.js (+1 -0) =================================================================== --- lib/server.js 2012-06-21 16:01:55 +0900 (95012a9) +++ lib/server.js 2012-06-21 16:00:36 +0900 (9282898) @@ -6,6 +6,7 @@ exports.createServer = function (config) { var database = new Database(config.database || config.databasePath); var application = express.createServer(); application.use(express.bodyParser()); + application.set('views', __dirname + '/../views'); api.versions.forEach(function(version) { api[version].registerHandlers(application, database); Modified: package.json (+2 -1) =================================================================== --- package.json 2012-06-21 16:01:55 +0900 (bb69350) +++ package.json 2012-06-21 16:00:36 +0900 (af25c4e) @@ -21,7 +21,8 @@ "nroonga": "git://github.com/nroonga/nroonga.git#master", "express": "", "jsdeferred": "", - "mkdirp": "" + "mkdirp": "", + "jade": "" }, "scripts": { "test": "./node_modules/.bin/mocha --reporter list --ui tdd", Modified: test/api-configuration.test.js (+2 -19) =================================================================== --- test/api-configuration.test.js 2012-06-21 16:01:55 +0900 (9eb1ac5) +++ test/api-configuration.test.js 2012-06-21 16:00:36 +0900 (355919a) @@ -99,7 +99,7 @@ suite('Configuration API', function() { }); test('Get, no version', function(done) { - var path = '/'; + var path = '/?Action=unknown'; utils.get(path) .next(function(response) { var message = 'An input parameter "Version" that is mandatory for ' + @@ -117,7 +117,7 @@ suite('Configuration API', function() { }); test('Get, invalid version', function(done) { - var path = '/?Version=2011-02-02'; + var path = '/?Version=2011-02-02&Action=unknown'; utils.get(path) .next(function(response) { var message = 'A bad or out-of-range value "2011-02-02" was supplied ' + @@ -134,23 +134,6 @@ suite('Configuration API', function() { }); }); - test('Get, no action', function(done) { - var path = '/?Version=2011-02-01'; - utils.get(path) - .next(function(response) { - var message = 'The request is missing an action or operation parameter.'; - var expected = { - statusCode: 400, - body: createCommonErrorResponse('MissingAction', message) - }; - assert.deepEqual(response, expected); - done(); - }) - .error(function(error) { - done(error); - }); - }); - test('Get, invalid action', function(done) { var path = '/?Version=2011-02-01&Action=unknown'; utils.get(path) Added: test/dashboard.test.js (+35 -0) 100644 =================================================================== --- /dev/null +++ test/dashboard.test.js 2012-06-21 16:00:36 +0900 (19780d5) @@ -0,0 +1,35 @@ +var utils = require('./test-utils'); +var assert = require('chai').assert; +var http = require('http'); +var fs = require('fs'); + +suite('dashboard', function() { + var server; + + setup(function() { + server = utils.setupServer(); + }); + + teardown(function() { + server.close(); + }); + + test('GET /', function(done) { + var options = { + host: utils.testHost, + port: utils.testPort, + path: '/' + }; + http.get(options, function(response) { + assert.equal(response.statusCode, 200); + var body = ''; + response.on('data', function(data) { + body += data; + }); + response.on('end', function() { + assert.match(body, /<h1>Groonga CloudSearch<\/h1>/); + done(); + }); + }); + }); +}); Added: views/index.jade (+1 -0) 100644 =================================================================== --- /dev/null +++ views/index.jade 2012-06-21 16:00:36 +0900 (18dda33) @@ -0,0 +1 @@ +h2 dashboard Added: views/layout.jade (+7 -0) 100644 =================================================================== --- /dev/null +++ views/layout.jade 2012-06-21 16:00:36 +0900 (141c36d) @@ -0,0 +1,7 @@ +doctype 5 +html + head + title Groonga CloudSearch + body + h1 Groonga CloudSearch + != body -------------- next part -------------- HTML$B$NE:IU%U%!%$%k$rJ]4I$7$^$7$?(B...Download