Merge pull request #1956 from Ich1goSan/feature/webhooks-api-refactoring
minor refactoring of Webhooks.API
This commit is contained in:
commit
efb39deea2
@ -2,18 +2,18 @@
|
|||||||
|
|
||||||
public class HttpGlobalExceptionFilter : IExceptionFilter
|
public class HttpGlobalExceptionFilter : IExceptionFilter
|
||||||
{
|
{
|
||||||
private readonly IWebHostEnvironment env;
|
private readonly IWebHostEnvironment _env;
|
||||||
private readonly ILogger<HttpGlobalExceptionFilter> logger;
|
private readonly ILogger<HttpGlobalExceptionFilter> _logger;
|
||||||
|
|
||||||
public HttpGlobalExceptionFilter(IWebHostEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
|
public HttpGlobalExceptionFilter(IWebHostEnvironment env, ILogger<HttpGlobalExceptionFilter> logger)
|
||||||
{
|
{
|
||||||
this.env = env;
|
_env = env;
|
||||||
this.logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnException(ExceptionContext context)
|
public void OnException(ExceptionContext context)
|
||||||
{
|
{
|
||||||
logger.LogError(new EventId(context.Exception.HResult),
|
_logger.LogError(new EventId(context.Exception.HResult),
|
||||||
context.Exception,
|
context.Exception,
|
||||||
context.Exception.Message);
|
context.Exception.Message);
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ public class HttpGlobalExceptionFilter : IExceptionFilter
|
|||||||
Detail = "Please refer to the errors property for additional details."
|
Detail = "Please refer to the errors property for additional details."
|
||||||
};
|
};
|
||||||
|
|
||||||
problemDetails.Errors.Add("DomainValidations", new string[] { context.Exception.Message.ToString() });
|
problemDetails.Errors.Add("DomainValidations", new [] { context.Exception.Message });
|
||||||
|
|
||||||
context.Result = new BadRequestObjectResult(problemDetails);
|
context.Result = new BadRequestObjectResult(problemDetails);
|
||||||
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.BadRequest;
|
||||||
@ -35,12 +35,12 @@ public class HttpGlobalExceptionFilter : IExceptionFilter
|
|||||||
{
|
{
|
||||||
var json = new JsonErrorResponse
|
var json = new JsonErrorResponse
|
||||||
{
|
{
|
||||||
Messages = new[] { "An error ocurred." }
|
Messages = new[] { "An error occurred." }
|
||||||
};
|
};
|
||||||
|
|
||||||
if (env.IsDevelopment())
|
if (_env.IsDevelopment())
|
||||||
{
|
{
|
||||||
json.DeveloperMeesage = context.Exception;
|
json.DeveloperMessage = context.Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
context.Result = new InternalServerErrorObjectResult(json);
|
context.Result = new InternalServerErrorObjectResult(json);
|
||||||
@ -53,6 +53,6 @@ public class HttpGlobalExceptionFilter : IExceptionFilter
|
|||||||
{
|
{
|
||||||
public string[] Messages { get; set; }
|
public string[] Messages { get; set; }
|
||||||
|
|
||||||
public object DeveloperMeesage { get; set; }
|
public object DeveloperMessage { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,6 @@ class GrantUrlTesterService : IGrantUrlTesterService
|
|||||||
|
|
||||||
return firstUrl.Scheme == secondUrl.Scheme &&
|
return firstUrl.Scheme == secondUrl.Scheme &&
|
||||||
firstUrl.Port == secondUrl.Port &&
|
firstUrl.Port == secondUrl.Port &&
|
||||||
firstUrl.Host == firstUrl.Host;
|
firstUrl.Host == secondUrl.Host;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
public class IdentityService : IIdentityService
|
public class IdentityService : IIdentityService
|
||||||
{
|
{
|
||||||
private IHttpContextAccessor _context;
|
private readonly IHttpContextAccessor _context;
|
||||||
|
|
||||||
public IdentityService(IHttpContextAccessor context)
|
public IdentityService(IHttpContextAccessor context)
|
||||||
{
|
{
|
||||||
|
@ -88,7 +88,7 @@ public class Startup
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static class CustomExtensionMethods
|
internal static class CustomExtensionMethods
|
||||||
{
|
{
|
||||||
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddAppInsight(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
@ -177,11 +177,11 @@ static class CustomExtensionMethods
|
|||||||
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
var serviceBusPersisterConnection = sp.GetRequiredService<IServiceBusPersisterConnection>();
|
||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusServiceBus>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubscriptionManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
string subscriptionName = configuration["SubscriptionClientName"];
|
string subscriptionName = configuration["SubscriptionClientName"];
|
||||||
|
|
||||||
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
return new EventBusServiceBus(serviceBusPersisterConnection, logger,
|
||||||
eventBusSubcriptionsManager, iLifetimeScope, subscriptionName);
|
eventBusSubscriptionManager, iLifetimeScope, subscriptionName);
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ static class CustomExtensionMethods
|
|||||||
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
var rabbitMQPersistentConnection = sp.GetRequiredService<IRabbitMQPersistentConnection>();
|
||||||
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
var iLifetimeScope = sp.GetRequiredService<ILifetimeScope>();
|
||||||
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
var logger = sp.GetRequiredService<ILogger<EventBusRabbitMQ>>();
|
||||||
var eventBusSubcriptionsManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
var eventBusSubscriptionManager = sp.GetRequiredService<IEventBusSubscriptionsManager>();
|
||||||
|
|
||||||
var retryCount = 5;
|
var retryCount = 5;
|
||||||
if (!string.IsNullOrEmpty(configuration["EventBusRetryCount"]))
|
if (!string.IsNullOrEmpty(configuration["EventBusRetryCount"]))
|
||||||
@ -201,7 +201,7 @@ static class CustomExtensionMethods
|
|||||||
retryCount = int.Parse(configuration["EventBusRetryCount"]);
|
retryCount = int.Parse(configuration["EventBusRetryCount"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubcriptionsManager, subscriptionClientName, retryCount);
|
return new EventBusRabbitMQ(rabbitMQPersistentConnection, logger, iLifetimeScope, eventBusSubscriptionManager, subscriptionClientName, retryCount);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,9 +215,6 @@ static class CustomExtensionMethods
|
|||||||
|
|
||||||
public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddCustomHealthCheck(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
var accountName = configuration.GetValue<string>("AzureStorageAccountName");
|
|
||||||
var accountKey = configuration.GetValue<string>("AzureStorageAccountKey");
|
|
||||||
|
|
||||||
var hcBuilder = services.AddHealthChecks();
|
var hcBuilder = services.AddHealthChecks();
|
||||||
|
|
||||||
hcBuilder
|
hcBuilder
|
||||||
|
Loading…
x
Reference in New Issue
Block a user