Exemple #1
0
        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);
            }
        };
Exemple #2
0
 public Task <Result <TResult> > Get <TResult>(Uri uri, HttpRequestInfo requestInfo) =>
 Get(uri, requestInfo)
 .Then(DeserializeJson <TResult>);
Exemple #3
0
 public Task <Result <string> > Get(Uri uri, HttpRequestInfo requestInfo) =>
 new HttpClient()
 .Tee(AddExtraInfo(requestInfo))
 .GetAsync(uri.AbsoluteUri)
 .Map(ResponseToResult);