Created
August 1, 2015 21:18
-
-
Save kevinsimper/5b962095aea3cb833d6c to your computer and use it in GitHub Desktop.
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 express = require('express') | |
var Promise = require('bluebird') | |
var app = express() | |
var request = require('request') | |
var through2 = require('through2') | |
app.all('*', function(req, res) { | |
var proxyRequest = request({ | |
url: 'http://requestb.in/ueod4pue', | |
method: req.method, | |
}) | |
proxyRequest.on('error', function(err) { | |
console.log('ERROR', err) | |
}) | |
proxyRequest.on('response', function(response) { | |
console.log('Answer', response.statusCode, response.headers['content-type']) | |
}) | |
req.pipe(proxyRequest).pipe(through2(function(chunk, enc, callback) { | |
console.log(chunk.toString()) | |
callback(null, chunk) | |
})).pipe(res) | |
}) | |
app.listen(9001) | |
// curl -X POST -d "fizz=buzz" http://localhost:9001/asd |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment