Created
April 10, 2011 00:26
-
-
Save DTrejo/911927 to your computer and use it in GitHub Desktop.
has a problem
This file contains hidden or 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
var http = require('http') | |
, httpProxy = require('http-proxy') | |
, ns = require('node-static') | |
, file = new(ns.Server)('./public') | |
, url = require('url') | |
, querystring = require('querystring') | |
; | |
// | |
// Create a proxy server with custom application logic | |
// | |
// httpProxy.createServer(function (req, res, proxy) { | |
// // proxy.proxyRequest(req, res, 80, 'flickr.com'); | |
// }).listen(8000); | |
httpProxy.createServer(function (request, response, proxy) { | |
request.addListener('end', function () { | |
var parsed = url.parse(request.url) | |
, params = querystring.parse(parsed.query) | |
; | |
if (params.p) { | |
console.log('bang!'); | |
proxy.proxyRequest(request, response, 80, 'flickr.com'); | |
} else { | |
file.serve(request, response); | |
} | |
}); | |
}).listen(8000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment