You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by GitBox <gi...@apache.org> on 2017/11/09 11:50:36 UTC

[GitHub] garrensmith closed pull request #1020: Support for closing couchdb server

garrensmith closed pull request #1020: Support for closing couchdb server
URL: https://github.com/apache/couchdb-fauxton/pull/1020
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/index.js b/index.js
index 98961004c..a17d629f6 100644
--- a/index.js
+++ b/index.js
@@ -35,13 +35,13 @@ module.exports = function (options) {
   }
 
   // create proxy to couch for all couch requests
-  var proxy = httpProxy.createServer({
+  this.proxy = httpProxy.createServer({
     secure: false,
     changeOrigin: true,
     target: proxyUrl
   });
 
-  http.createServer(function (req, res) {
+  this.server = http.createServer((req, res) => {
     var isDocLink = /_utils\/docs/.test(req.url);
     var url = req.url.split(/\?v=|\?noCache/)[0].replace('_utils', '');
     var accept = [];
@@ -66,16 +66,16 @@ module.exports = function (options) {
     var urlObj = urlLib.parse(req.url);
     req.headers.host = urlObj.host;
 
-    proxy.web(req, res);
+    this.proxy.web(req, res);
   }).listen(port, '0.0.0.0');
 
-  proxy.on('error', () => {
+  this.proxy.on('error', () => {
     // don't explode on cancelled requests
   });
 
   //Remove Secure on the cookie if the proxy is communicating to a CouchDB instance
   // via https.
-  proxy.on('proxyRes', function (proxyRes) {
+  this.proxy.on('proxyRes', (proxyRes) => {
     if (proxyRes.headers['set-cookie']) {
       proxyRes.headers['set-cookie'][0] = proxyRes.headers["set-cookie"][0].replace('Secure', '');
     }
@@ -97,4 +97,11 @@ module.exports = function (options) {
   });
 
   console.log('Listening on ' + port);
+
+  this.close = () => {
+    this.server.close();
+    this.proxy.close();
+  };
+
+  return this;
 };


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services