Skip to content

Instantly share code, notes, and snippets.

@kevinsimper
Created August 1, 2015 21:18
Show Gist options
  • Save kevinsimper/5b962095aea3cb833d6c to your computer and use it in GitHub Desktop.
Save kevinsimper/5b962095aea3cb833d6c to your computer and use it in GitHub Desktop.
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