Bug:Fix file validation issue
[vnfsdk/refrepo.git] / vnfmarket / src / main / webapp / vnfmarket / node_modules / http-proxy / examples / middleware / url-middleware2.js
1 var util = require('util'),
2     colors = require('colors'),
3     http = require('http'),
4     httpProxy = require('../../lib/node-http-proxy'),
5     Store = require('../helpers/store') 
6
7 http.createServer(new Store().handler()).listen(7531)
8
9 // Now we set up our proxy.
10 httpProxy.createServer(
11   // This is where our middlewares go, with any options desired - in this case,
12   // the list of routes/URLs and their destinations.
13   require('proxy-by-url')({
14     '/store': { port: 7531, host: 'localhost' },
15     '/': { port: 9000, host: 'localhost' }
16   })
17 ).listen(8000);
18
19 //
20 // Target Http Server (to listen for requests on 'localhost')
21 //
22 http.createServer(function (req, res) {
23   res.writeHead(200, { 'Content-Type': 'text/plain' });
24   res.write('request successfully proxied to: ' + req.url + '\n' + JSON.stringify(req.headers, true, 2));
25   res.end();
26 }).listen(9000);
27
28 // And finally, some colored startup output.
29 util.puts('http proxy server'.blue + ' started '.green.bold + 'on port '.blue + '8000'.yellow);
30 util.puts('http server '.blue + 'started '.green.bold + 'on port '.blue + '9000 '.yellow);