Created
April 14, 2018 21:17
-
-
Save alexandrebl/ee6635cb8b6a895d90c554a7cd5fa7e4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.Collections.Generic; | |
| using System.Collections.ObjectModel; | |
| using System.Net; | |
| using System.Net.Http; | |
| using BinanceCryptoCurrency.Domain; | |
| using BinanceCryptoCurrency.Domain.Entity; | |
| using Newtonsoft.Json; | |
| namespace BinanceCryptoCurrency.Utility { | |
| public class HttpUtilityTool { | |
| private static readonly HttpClient HttpClient | |
| = new HttpClient(new HttpClientHandler() { MaxConnectionsPerServer = 2000 }); | |
| private readonly ILogger _logger; | |
| public HttpUtilityTool(ILogger logger) { | |
| _logger = logger; | |
| } | |
| public HttpResponseMessage GetData(Uri uri) { | |
| try { | |
| HttpClient.BaseAddress = uri; | |
| var httpRequestTask = HttpClient.GetAsync(uri); | |
| var httpResponseMessage = httpRequestTask.Result; | |
| return httpResponseMessage; | |
| } catch (Exception ex) { | |
| _logger.Write(ex); | |
| return new HttpResponseMessage(HttpStatusCode.InternalServerError); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment