RestCode / WebApiProxy

MIT License
199 stars 91 forks source link

Generated Proxies Should Create Constructors Accepting Strings/Uris #24

Closed Mike-E-angelo closed 8 years ago

Mike-E-angelo commented 10 years ago

Hello,

I just noticed that generated clients depend on a hard-coded string that also gets generated. This does not account for environment-specific use cases where the URL of the service will change based on the environment. The generated proxies should create constructors that accept both strings and URIs so that the base address can be assigned via configuration based on the target environment. I will definitely be providing a PR for this. :)

Thank you, Michael

faniereynders commented 9 years ago

That's a great idea @Michael-DST!

In the meanwhile, here is a workaround for the C# client. You have access to the normal ASP.NET WebApi Client, just simply set the BaseAddress here:

using (var client = new PeopleClient())
{
   client.HttpClient.BaseAddress = new Uri("http://dev.some-other-url.com");
   var response = await client.GetAsync();
   response.EnsureSuccessStatusCode();
   var content = await response.Content.ReadAsAsync<object>();
}
wolfen351 commented 8 years ago

This should be quite easy to add, any chance of a pull request?

faniereynders commented 8 years ago

Merged with #49