wis3guy / HalClient.Net

A library that simplifies interaction with API's that respond with the "application\hal+json" media type.
Microsoft Public License
19 stars 21 forks source link

Add optional httpclient argument to HalHttpClientFactory #1

Closed haraldq closed 9 years ago

haraldq commented 9 years ago

In this way, HalClient can be used with Owin Testserver in this manner:

    [Fact]
    public async Task UseHalClientWithOwinTestServer()
    {
        var factory = new HalHttpClientFactory(new HalJsonParser());

        using (var server = Microsoft.Owin.Testing.TestServer.Create<Startup>())
        using (var client = factory.CreateClient(server.HttpClient))
        {
            var customers = await client.GetAsync(new Uri("http://mytestserver/customers/7809"));
        }
    }
wis3guy commented 9 years ago

This is a really nice addition! Thanks for the pull-request.

wis3guy commented 8 years ago

@haraldq This is just to inform you that i have rewritten the documentation and dedicated a section to this: https://github.com/wis3guy/HalClient.Net#i-want-to-use-a-custom-httpclient-for-my-ihalhttpclient-instances

Also note that in my experience, for testing purposes, it is easier to use a custom handler, as described here: https://github.com/wis3guy/HalClient.Net#i-want-to-use-a-custom-httpmessagehandler-for-my-ihalhttpclient-instances