Closed eastlondoner closed 8 years ago
This is a good idea. In my local copy I've also expanded the template:
protected ClientBase()
{
HttpClient = new HttpClient()
{
BaseAddress = new Uri(Configuration.<#= Configuration.Name #>BaseAddress)
};
}
protected ClientBase(HttpClient client)
{
HttpClient = client;
}
protected ClientBase(HttpMessageHandler handler, bool disposeHandler = true)
{
HttpClient = new HttpClient(handler, disposeHandler)
{
BaseAddress = new Uri(Configuration.<#= Configuration.Name #>BaseAddress)
};
}
HttpMessageHandler
allows me to implement a Transient Fault Handling strategy.
@eastlondoner talk is cheap, show me the PR :smile:
FYI - The generated classes are all partial, meaning it can be extended from your own code, so no need to edit/expand the local template @mawt
In the meanwhile, I'm closing this issue for now, but am happy to look at it again once we've received a feasible PR.
Thanks for the feedback tho.
Hi there, This is an amazingly useful piece of work. Well done!
I want to be able to add headers to the ClientBase HttpClient DefaultRequestHeaders automatically.
I can see that ClientBase is partial so I can add my own methods etc. to it but I cannot see any way to add to it such that it would be able to always ensure that headers were added 'automagically'
Is there a good way to do this?
If not would it be appropriate to add some extensibility to ClientBase e.g. adding
I'm happy to make a PR for this or similar if you think it's appropriate?