Example #1
0
 private static HttpClientRegistrator ConfigureBaseClient(WebapiEndpoint endpoint)
 {
     return(HttpClientRegistrator.Create()
            .WithName(endpoint.Name)
            .WithUrl(endpoint.Url)
            .WithTimeout(endpoint.Timeout)
            .WithHandler <BaseCompanyRequestHeadersHandler>());
 }
Example #2
0
 private static HttpClientRegistrator ConfigureNtlmClient(WebapiEndpoint endpoint)
 {
     return(ConfigureBaseClient(endpoint)
            .ConfigureBuilder(x =>
     {
         x.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler()
         {
             AllowAutoRedirect = false, UseDefaultCredentials = true, PreAuthenticate = true
         });
     }));
 }
Example #3
0
 /// <summary>
 /// Создаёт и конфигурирует Http-клиенты
 /// </summary>
 private static HttpClientRegistrator ConfigureClient(WebapiEndpoint endpoint)
 {
     return(HttpClientRegistrator.Create()
            .WithName(endpoint.Name)
            .WithUrl(endpoint.Url)
            .WithTimeout(endpoint.Timeout)
            .WithHandler <BaseCompanyRequestHeadersHandler>()
            .ConfigureBuilder(x => x.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler
     {
         AllowAutoRedirect = false,
         UseProxy = false
     })));
 }
Example #4
0
        private static async Task <DiagnosticInfo> PingEndpoint(WebapiEndpoint endpoint, System.Net.Http.HttpClient client)
        {
            try
            {
                Logger.LogDiagnostic($"Diagnosting the REST endpoint {endpoint.Name}");
                var pinged = DiagnosticStatus.PingError;

                using (var response = await client.GetAsync("/diagnostic/ping"))
                {
                    if (response.IsSuccessStatusCode)
                    {
                        pinged = DiagnosticStatus.Ok;
                        Logger.LogDiagnostic($"REST endpoint {endpoint.Name} has been diagnosed successfully");
                    }
                }

                return(new DiagnosticInfo(endpoint.Name, endpoint.Url, pinged));
            }
            catch (Exception e)
            {
                Logger.LogDiagnostic($"Diagnostic of REST endpoint {endpoint.Name} has been failed with error: {e}");
                return(new DiagnosticInfo(endpoint.Name, endpoint.Url, DiagnosticStatus.PingError, string.Empty, e.ToString()));
            }
        }