private static Action <HttpClient> AddExtraInfo(HttpRequestInfo info) => client => { if (info.Authentication is Some <AuthenticationHeaderValue> s) { client.DefaultRequestHeaders.Authorization = s.Value; } foreach (var(key, value) in info.Headers) { client.DefaultRequestHeaders.Add(key, value); } };
public Task <Result <TResult> > Get <TResult>(Uri uri, HttpRequestInfo requestInfo) => Get(uri, requestInfo) .Then(DeserializeJson <TResult>);
public Task <Result <string> > Get(Uri uri, HttpRequestInfo requestInfo) => new HttpClient() .Tee(AddExtraInfo(requestInfo)) .GetAsync(uri.AbsoluteUri) .Map(ResponseToResult);