HttpTracer
HttpTracer copied to clipboard
trouble getting started, Visual Studio + Refit example
Hi there, I found your library in the course of trying to troubleshoot a Refit issue. It's one of those cases where I can make it work in Postman, but I'm not sure how to reproduce it correctly for Refit. The issue is I'm not seeing any trace output in the Debug window when I run my project. I've made a little walkthrough:
https://1drv.ms/u/s!AvguHRnyJtWMmeh7C8wHrd7X8BbDyA?e=tcCcNZ
Here's my relevant code: https://github.com/adamfoneil/GitHubApi/blob/master/MicropubApi.Library/MicropubApiClient.cs#L17
I went ahead and used Fiddler to get debug my immediate issue. The line number URL above is no longer relevant because I removed the trace stuff, but I'm still interested to hear your feedback.
Hey Adam, I've setup our lib with Refit before, I will write something up and share, so you can check out too.
@DanielCauser did you ever get around to doing your writeup?
I did, and I will bring this up here this weekend.
Perhaps a Wiki in the new organization?
Refit + HttpTracer Example
Checkout below steps for Refit https://gist.github.com/hamid-shaikh/24d93419f9b5313685c4dfc40f4b59dc
For HttpTracer implementation just simply replace HttpClient creation with below snippet
HttpClient restClient;
HttpClient RestClient
{
get
{
if (restClient != null)
return restClient;
var builder = new HttpHandlerBuilder();
builder.AddHandler(new AppMessageHandler());
var tracer = builder.Build();
restClient = new HttpClient(tracer)
{
BaseAddress = new Uri(GetBaseAddress()),//App Base URI
Timeout = TimeSpan.FromSeconds(APIConstants.Timeout)//Timeout time for HTTP Request
};
restClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
return restClient;
}
}