-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Alexej Yaroshevich
committed
Dec 16, 2013
1 parent
800a7bf
commit c1d2b06
Showing
4 changed files
with
22 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,12 @@ | ||
|
||
var http = require('http') | ||
, bemRender = require('lib/bem-render-middleware') | ||
var bemRender = require('lib/bem-render-middleware') | ||
, httpProxy = require('http-proxy'); | ||
|
||
httpProxy.createServer( | ||
bemRender.pages('pages'), | ||
bemRender.bundles('pages'), | ||
function (req, res, next) { | ||
res.setHeader('X-Powered-By', 'bem-proxy'); | ||
next(); | ||
}, | ||
9000, 'localhost' | ||
).listen(8001); | ||
|
||
http.createServer(function (req, res) { | ||
require('fs').readFile('bem-examples/www/pages/example/example.bemjson.js', function (err, data) { | ||
if (err) { | ||
res.writeHead(500); | ||
res.end('Something went wrong: ' + e.message); | ||
res.end(); | ||
return; | ||
} | ||
res.writeHead(200, { 'Content-Type': 'application/x-bemjson' }); | ||
res.write(data); | ||
res.end(); | ||
}); | ||
}).listen(9000); | ||
|
||
/* | ||
http.createServer(function (req, res) { | ||
http.get("http://interactive-answers.yandex.ru/api/2.x/site/d89cda99-274e-47be-abe5-ac0ed339a083/search", function (gres) { | ||
res.writeHead(200, { 'Content-Type': 'application/x-bemjson' }); | ||
res.write('request successfully proxied: ' + req.url +'\n'); | ||
res.write(JSON.stringify(req.headers, true, 2)); | ||
res.write(JSON.stringify(gres.headers, true, 2)); | ||
gres.on('data', function (chunk) { | ||
res.write(chunk); | ||
}); | ||
gres.on('end', function (chunk) { | ||
res.end(); | ||
}); | ||
}).on('error', function (e) { | ||
res.writeHead(500); | ||
res.end('Something went wrong: ' + e.message); | ||
}); | ||
}).listen(9000); | ||
*/ | ||
80, 'localhost' | ||
).listen(process.env.NODE_PORT); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
var bemRender = require('lib/bem-render-middleware') | ||
, httpProxy = require('http-proxy'); | ||
|
||
exports.createServer = function (path, port, host) { | ||
port = port || 80; | ||
host = host || 'localhost'; | ||
return httpProxy.createServer( | ||
bemRender.bundles(path), | ||
function (req, res, next) { | ||
res.setHeader('X-Powered-By', 'bem-proxy'); | ||
next(); | ||
}, | ||
port, host | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters