| | |
| | | { |
| | | public class HttpHelper |
| | | { |
| | | public static async Task<string> GetAsync(string serviceAddress, string contentType = "application/json", Dictionary<string, string>? headers = null) |
| | | public static async Task<string> GetAsync(string serviceAddress, Dictionary<string, string>? headers = null) |
| | | { |
| | | string result = string.Empty; |
| | | DateTime beginDate = DateTime.Now; |
| | |
| | | { |
| | | using HttpClient httpClient = new HttpClient(); |
| | | httpClient.Timeout = new TimeSpan(0, 0, 60); |
| | | |
| | | |
| | | if (headers != null) |
| | | { |
| | | foreach (var header in headers) |
| | |
| | | } |
| | | } |
| | | |
| | | public static async Task<string?> PostAsync(string serviceAddress, string requestJson = null, string contentType = "application/json", Dictionary<string, string>? headers = null) |
| | | public static async Task<string?> PostAsync(string serviceAddress, string requestJson = "", string contentType = "application/json", Dictionary<string, string>? headers = null) |
| | | { |
| | | string result = string.Empty; |
| | | DateTime beginDate = DateTime.Now; |
| | |
| | | } |
| | | finally |
| | | { |
| | | Logger.Add(serviceAddress, requestJson == null ? "" : requestJson, result, beginDate); |
| | | Logger.Add(serviceAddress, requestJson, result, beginDate); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | public static string Post(string serviceAddress, string requestJson = null, string contentType = "application/json", Dictionary<string, string>? headers = null) |
| | | public static string Post(string serviceAddress, string requestJson = "", string contentType = "application/json", Dictionary<string, string>? headers = null) |
| | | { |
| | | string result = string.Empty; |
| | | DateTime beginDate = DateTime.Now; |
| | |
| | | } |
| | | finally |
| | | { |
| | | Logger.Add(serviceAddress, requestJson == null ? "" : requestJson, result, beginDate); |
| | | Logger.Add(serviceAddress, requestJson, result, beginDate); |
| | | } |
| | | } |
| | | } |