| | |
| | | using System.Threading.Tasks; |
| | | using Microsoft.Extensions.Configuration; |
| | | using Microsoft.Extensions.Logging; |
| | | using Newtonsoft.Json; |
| | | using WIDESEA_Core.Helper; |
| | | |
| | | namespace WIDESEA_Core.Util |
| | |
| | | SetRequestHeaders(request, config?.Headers); |
| | | return await client.SendAsync(request); |
| | | }, config, $"POST {url}").Result; |
| | | |
| | | httpResponseResult.ApiUrl = url; |
| | | return httpResponseResult; |
| | | } |
| | | |
| | |
| | | return await client.SendAsync(request); |
| | | }, config, $"GET {url}").Result; |
| | | |
| | | httpResponseResult.ApiUrl = url; |
| | | return httpResponseResult; |
| | | } |
| | | |
| | |
| | | { |
| | | try |
| | | { |
| | | TResponse? response = JsonSerializer.Deserialize<TResponse>(result.Content, new JsonSerializerOptions |
| | | { |
| | | PropertyNameCaseInsensitive = true |
| | | }); |
| | | TResponse? response = JsonConvert.DeserializeObject<TResponse>(result.Content); |
| | | if (response != null) |
| | | { |
| | | result.Data = response; |
| | |
| | | { |
| | | try |
| | | { |
| | | TResponse? response = JsonSerializer.Deserialize<TResponse>(result.Content, new JsonSerializerOptions |
| | | { |
| | | PropertyNameCaseInsensitive = true |
| | | }); |
| | | TResponse? response = JsonConvert.DeserializeObject<TResponse>(result.Content); |
| | | if (response != null) |
| | | { |
| | | result.Data = response; |
| | |
| | | try |
| | | { |
| | | response = await requestFunc(client); |
| | | break; |
| | | if (response.StatusCode == System.Net.HttpStatusCode.OK) |
| | | break; |
| | | } |
| | | catch (Exception ex) when (retry < config.MaxRetryCount) |
| | | { |