Sha256: a745419b57a4058bf0672494dc6ac13a3e6920eacddd312235c1422fbc3f829d

Contents?: true

Size: 1.07 KB

Versions: 17

Compression:

Stored size: 1.07 KB

Contents

var util = require('util'),
    colors = require('colors'),
    http = require('http'),
    httpProxy = require('../../lib/node-http-proxy'),
    Store = require('../helpers/store') 

http.createServer(new Store().handler()).listen(7531)

// Now we set up our proxy.
httpProxy.createServer(
  // This is where our middlewares go, with any options desired - in this case,
  // the list of routes/URLs and their destinations.
  require('proxy-by-url')({
    '/store': { port: 7531, host: 'localhost' },
    '/': { port: 9000, host: 'localhost' }
  })
).listen(8000);

//
// Target Http Server (to listen for requests on 'localhost')
//
http.createServer(function (req, res) {
  res.writeHead(200, { 'Content-Type': 'text/plain' });
  res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
  res.end();
}).listen(9000);

// And finally, some colored startup output.
util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
hooch-0.4.2 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.4.1 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.4.0 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.3.0 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.2.1 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.2.0 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.1.0 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.0.8 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.0.7 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
hooch-0.0.6 jasmine/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
entangled-0.0.16 spec/dummy/public/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
entangled-0.0.15 spec/dummy/public/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
entangled-0.0.14 spec/dummy/public/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
entangled-0.0.13 spec/dummy/public/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
entangled-0.0.12 spec/dummy/public/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
entangled-0.0.11 spec/dummy/public/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js
entangled-0.0.10 spec/dummy/public/node_modules/karma/node_modules/http-proxy/examples/middleware/url-middleware2.js