public Context(string key, bool shouldSendRequest = true) { var httpHandler = new CustomHttpClientHandler(shouldSendRequest); var httpClient = new HttpClient(httpHandler) { BaseAddress = new Uri("https://api.sendgrid.com/v3/") }; _context = new RestClient(httpClient).AddJsonBodySerializer().For <IContext>(); _context.ApiKey = $"Bearer {key}"; _context.ContentType = "application/json"; }
public async Task DoWithRefitUsingHttpClientHandler() { Task <string> GetHeaderValue() => Task.FromResult("other header value"); var handler = new CustomHttpClientHandler(GetHeaderValue); var httpClient = new HttpClient(handler) { BaseAddress = new Uri("http://localhost:5000") }; var api = RestService.For <IResources>(httpClient); string response = await api.Get(); Assert.Equal("x-test:other header value", response); }