bcuff / GeocodeSharp

An async .NET client for the Google geocode API
Apache License 2.0
10 stars 20 forks source link

Proxy support #14

Closed chester89 closed 8 years ago

chester89 commented 8 years ago

To cover #13

chester89 commented 8 years ago

I think NginxProxyRequestBuilder isn't needed in the library, I'll remove it

chester89 commented 8 years ago

Ok, ready for your review @bcuff

chester89 commented 8 years ago

The weird changeset for the project file is due to inconsistent line endings, I guess

bcuff commented 8 years ago

Thanks for the PR. Hmm... is it really necessary to pull so much of the client into the abstraction? The client doesn't do much anymore. I would think that something like the following would be sufficient and would only require a very small change.

public interface IGeocodeProxyProvider
{
    // If a proxy was specified to the client it would call this to
    // this in DoWebRequest instead of WebRequest.CreateHttp(url);
    HttpWebRequest CreateRequest(string url);
}

Then a proxy implementation might look something like this

public class MyGeocodeProxy : IGeocodeProxyProvider
{
    public HttpWebRequest CreateRequest(string url)
    {
        url = new UriBuilder(url)
        {
            Host = "geocodeproxy.mydomain.com",
            Port = 8080
        }.Uri.ToString();
        return WebRequest.CreateHttp(url);
    }
}

Would this give you the power you need? Maybe I missed something?

chester89 commented 8 years ago

Well, that should work, and it's definitely much simpler design than mine. I guess, in your case, the logic of url building (adding parameters, mostly) will remain in the GeocodeClient class?

2016-08-12 16:51 GMT+03:00 Brandon notifications@github.com:

Thanks for the PR. Hmm... is it really necessary to pull so much of the client into the abstraction? The client doesn't do much anymore. I would think that something like the following would be sufficient and would only require a very small change.

public interface IGeocodeProxyProvider { // If a proxy was specified to the client it would call this to // this in DoWebRequest instead of WebRequest.CreateHttp(url); HttpWebRequest CreateRequest(string url); }

Then a proxy implementation might look something like this

public class MyGeocodeProxy : IGeocodeProxyProvider { public HttpWebRequest CreateRequest(string url) { url = new UriBuilder(url) { Host = "geocodeproxy.mydomain.com", Port = 8080 }.Uri.ToString(); return WebRequest.CreateHttp(url); } }

Would this give you the power you need? Maybe I missed something?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/bcuff/GeocodeSharp/pull/14#issuecomment-239451559, or mute the thread https://github.com/notifications/unsubscribe-auth/AALnfOGuAjfRqzmgf_0mxTJ8t08MgdDWks5qfHpkgaJpZM4JiNgY .

Yours faithfully, Gleb

bcuff commented 8 years ago

Yes. You would just get the opportunity to make adjustments to the request before it was sent.

chester89 commented 8 years ago

Closed in favor of #15