[Groonga-commit] groonga/gcs [master] Add the port number as a part of the endpoint

Zurück zum Archiv-Index

SHIMODA Hiroshi null+****@clear*****
Wed Aug 15 13:40:29 JST 2012


SHIMODA Hiroshi	2012-08-15 13:40:29 +0900 (Wed, 15 Aug 2012)

  New Revision: ab13ce19f468be67d82f46dc9c4ac24826ca9a80
  https://github.com/groonga/gcs/commit/ab13ce19f468be67d82f46dc9c4ac24826ca9a80

  Log:
    Add the port number as a part of the endpoint

  Modified files:
    bin/gcs
    lib/api/2011-02-01/configuration.js

  Modified: bin/gcs (+2 -1)
===================================================================
--- bin/gcs    2012-08-15 13:24:27 +0900 (8ae6380)
+++ bin/gcs    2012-08-15 13:40:29 +0900 (18b4b50)
@@ -18,7 +18,8 @@ commandLine
 
 var server = gcsServer.createServer({
       databasePath:     commandLine.options.databasePath,
-      privilegedRanges: commandLine.options.privilege
+      privilegedRanges: commandLine.options.privilege,
+      port:             commandLine.options.port
     });
 
 server.listen(commandLine.options.port, function() {

  Modified: lib/api/2011-02-01/configuration.js (+32 -27)
===================================================================
--- lib/api/2011-02-01/configuration.js    2012-08-15 13:24:27 +0900 (ec28ab3)
+++ lib/api/2011-02-01/configuration.js    2012-08-15 13:40:29 +0900 (43dc7b5)
@@ -25,8 +25,13 @@ function createCommonErrorResponse(errorCode, error) {
 var handlers = Object.create(null);
 
 
-function getBaseDomain(domain) {
-  return domain.replace(/^cloudsearch\./, '');
+function getBaseHostAndPort(request, config) {
+  var host = request.headers.host;
+  var baseHost = host.replace(/^cloudsearch\./, '');
+  if (config.port == 80)
+    return baseHost;
+  else
+    return baseHost + ':' + config.port;
 }
 
 function createDomainStatus(options) {
@@ -35,7 +40,7 @@ function createDomainStatus(options) {
     .element('Created').text(options.created || 'false').up()
     .element('Deleted').text(options.deleted || 'false').up()
     .element('DocService')
-      .element('Endpoint').text(options.domain.getDocumentsEndpoint(options.hostname)).up()
+      .element('Endpoint').text(options.domain.getDocumentsEndpoint(options.hostAndPort)).up()
     .up()
     .element('DomainId')
       .text(options.domain.domainId)
@@ -54,7 +59,7 @@ function createDomainStatus(options) {
       .text(options.domain.searchPartitionCount)
     .up()
     .element('SearchService')
-      .element('Endpoint').text(options.domain.getSearchEndpoint(options.hostname)).up()
+      .element('Endpoint').text(options.domain.getSearchEndpoint(options.hostAndPort)).up()
     .up();
   return domainStatus;
 }
@@ -72,15 +77,15 @@ function createCreateDomainResponse(options) {
   return doc.toString();
 }
 
-handlers.CreateDomain = function(context, request, response) {
+handlers.CreateDomain = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
   try {
     domain.createSync();
     response.contentType('application/xml');
     response.send(createCreateDomainResponse({
-      domain: domain,
-      hostname: getBaseDomain(request.headers.host),
-      created: true
+      domain:      domain,
+      hostAndPort: getBaseHostAndPort(request, config),
+      created:     true
     }));
   } catch (error) {
     var body = createCommonErrorResponse('InternalFailure', error);
@@ -102,15 +107,15 @@ function createDeleteDomainResponse(options) {
   return doc.toString();
 }
 
-handlers.DeleteDomain = function(context, request, response) {
+handlers.DeleteDomain = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
   try {
     domain.deleteSync();
     response.contentType('application/xml');
     response.send(createDeleteDomainResponse({
-      domain: domain,
-      hostname: getBaseDomain(request.headers.host),
-      deleted: true
+      domain:      domain,
+      hostAndPort: getBaseHostAndPort(request, config),
+      deleted:     true
     }));
   } catch (error) {
     var body = createCommonErrorResponse('InternalFailure',
@@ -125,9 +130,9 @@ function createDomainStatusList(options) {
   var domainStatusList = doc.begin('DomainStatusList', {version: '1.0'});
   options.domains.forEach(function(domain) {
     domainStatusList.importXMLBuilder(createDomainStatus({
-                       domain:   domain,
-                       hostname: options.hostname,
-                       element:  'member'
+                       domain:      domain,
+                       hostAndPort: options.hostAndPort,
+                       element:     'member'
                      }));
   });
   return doc;
@@ -146,7 +151,7 @@ function createDescribeDomainsResponse(options) {
   return doc.toString();
 }
 
-handlers.DescribeDomains = function(context, request, response) {
+handlers.DescribeDomains = function(context, request, response, config) {
   try {
     var keys = Object.keys(request.query).filter(function(key) {
           return /^DomainNames\.member\.\d+$/.test(key);
@@ -161,8 +166,8 @@ handlers.DescribeDomains = function(context, request, response) {
                     Domain.getAll(context) ;
     response.contentType('application/xml');
     response.send(createDescribeDomainsResponse({
-      domains: domains,
-      hostname: getBaseDomain(request.headers.host)
+      domains:     domains,
+      hostAndPort: getBaseHostAndPort(request, config)
     }));
   } catch (error) {
     var body = createCommonErrorResponse('InternalFailure',
@@ -247,7 +252,7 @@ function getFieldOption(option, request, type) {
     return request.query['UIntOptions.' + option];
 }
 
-handlers.DefineIndexField = function(context, request, response) {
+handlers.DefineIndexField = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
 
   var fieldName = request.query['IndexField.IndexFieldName'] || '';
@@ -301,7 +306,7 @@ function createDeleteIndexFieldResponse(options) {
   return doc.toString();
 }
 
-handlers.DeleteIndexField = function(context, request, response) {
+handlers.DeleteIndexField = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
 
   var fieldName = request.query['IndexFieldName'] || '';
@@ -343,7 +348,7 @@ function createDescribeIndexFieldsResponse(options) {
   return doc.toString();
 }
 
-handlers.DescribeIndexFields = function(context, request, response) {
+handlers.DescribeIndexFields = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
 
   try {
@@ -395,7 +400,7 @@ function createIndexDocumentsResponse(options) {
   return doc.toString();
 }
 
-handlers.IndexDocuments = function(context, request, response) {
+handlers.IndexDocuments = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
   try {
     domain.reindexSync();
@@ -441,7 +446,7 @@ function createUpdateSynonymOptionsResponse(options) {
   return doc.toString();
 }
 
-handlers.UpdateSynonymOptions = function(context, request, response) {
+handlers.UpdateSynonymOptions = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
   try {
     var synonymOptionsJson = request.query.Synonyms;
@@ -475,7 +480,7 @@ function createDescribeSynonymOptionsResponse(options) {
   return doc.toString();
 }
 
-handlers.DescribeSynonymOptions = function(context, request, response) {
+handlers.DescribeSynonymOptions = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
   try {
     var updatedAt = new Date();
@@ -526,7 +531,7 @@ function createUpdateDefaultSearchFieldResponse(options) {
   return doc.toString();
 }
 
-handlers.UpdateDefaultSearchField = function(context, request, response) {
+handlers.UpdateDefaultSearchField = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
   try {
     var fieldName = request.query.DefaultSearchField;
@@ -565,7 +570,7 @@ function createDescribeDefaultSearchFieldResponse(options) {
   return doc.toString();
 }
 
-handlers.DescribeDefaultSearchField = function(context, request, response) {
+handlers.DescribeDefaultSearchField = function(context, request, response, config) {
   var domain = new Domain(request.query.DomainName, context);
   try {
     var field = domain.defaultSearchField;
@@ -644,6 +649,6 @@ exports.createHandler = function(context, config) {
     }
 
     var handler = handlers[action];
-    handler(context, request, response);
+    handler(context, request, response, config);
   };
 };
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Zurück zum Archiv-Index