elazarl/goproxy — pull request #56 by BenPhegan (2014-07-15 11:57:36+00:00)
Title: Add ability to accept direct non-proxy connections

Hi,

Have been building out a little service stubbing tool here based on your library (which is great by the way!): https://github.com/BenPhegan/fauxpi

One thing that would be useful is to be able to accept direct as well as proxied connections to enable service stubbing directly for apps that do not support proxy use.

A recent change https://github.com/elazarl/goproxy/commit/44e67200a91914114c155004d63afa8babc86f00 has prevented direct connections, which is a good fix for the problem it addresses.

This pull request is to make this the default behaviour still, but enable the proxy to be set to respond to direct requests via setting an AcceptDirect bool on the proxy object.

Very new to Golang, so not sure if there is a better way to do this or whether the tests (copied from the inverse) are correct. Happy to discuss further!

Regards,

Ben Phegan