|
@ -6,7 +6,6 @@ using Microsoft.AspNetCore.Authentication.JwtBearer; |
|
|
using Microsoft.AspNetCore.Builder; |
|
|
using Microsoft.AspNetCore.Builder; |
|
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks; |
|
|
using Microsoft.AspNetCore.Diagnostics.HealthChecks; |
|
|
using Microsoft.AspNetCore.Http; |
|
|
using Microsoft.AspNetCore.Http; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
|
|
|
using Microsoft.Azure.ServiceBus; |
|
|
using Microsoft.Azure.ServiceBus; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore.Diagnostics; |
|
|
using Microsoft.EntityFrameworkCore.Diagnostics; |
|
@ -47,7 +46,7 @@ namespace Webhooks.API |
|
|
{ |
|
|
{ |
|
|
services |
|
|
services |
|
|
.AddAppInsight(Configuration) |
|
|
.AddAppInsight(Configuration) |
|
|
.AddCustomMVC(Configuration) |
|
|
|
|
|
|
|
|
.AddCustomRouting(Configuration) |
|
|
.AddCustomDbContext(Configuration) |
|
|
.AddCustomDbContext(Configuration) |
|
|
.AddSwagger(Configuration) |
|
|
.AddSwagger(Configuration) |
|
|
.AddCustomHealthCheck(Configuration) |
|
|
.AddCustomHealthCheck(Configuration) |
|
@ -62,8 +61,6 @@ namespace Webhooks.API |
|
|
.AddTransient<IWebhooksRetriever, WebhooksRetriever>() |
|
|
.AddTransient<IWebhooksRetriever, WebhooksRetriever>() |
|
|
.AddTransient<IWebhooksSender, WebhooksSender>(); |
|
|
.AddTransient<IWebhooksSender, WebhooksSender>(); |
|
|
|
|
|
|
|
|
services.AddControllers(); |
|
|
|
|
|
|
|
|
|
|
|
var container = new ContainerBuilder(); |
|
|
var container = new ContainerBuilder(); |
|
|
container.Populate(services); |
|
|
container.Populate(services); |
|
|
return new AutofacServiceProvider(container.Build()); |
|
|
return new AutofacServiceProvider(container.Build()); |
|
@ -85,10 +82,12 @@ namespace Webhooks.API |
|
|
|
|
|
|
|
|
ConfigureAuth(app); |
|
|
ConfigureAuth(app); |
|
|
|
|
|
|
|
|
|
|
|
app.UseAuthorization(); |
|
|
app.UseRouting(); |
|
|
app.UseRouting(); |
|
|
app.UseEndpoints(endpoints => |
|
|
app.UseEndpoints(endpoints => |
|
|
{ |
|
|
{ |
|
|
endpoints.MapDefaultControllerRoute(); |
|
|
endpoints.MapDefaultControllerRoute(); |
|
|
|
|
|
endpoints.MapControllers(); |
|
|
endpoints.MapHealthChecks("/hc", new HealthCheckOptions() |
|
|
endpoints.MapHealthChecks("/hc", new HealthCheckOptions() |
|
|
{ |
|
|
{ |
|
|
Predicate = _ => true, |
|
|
Predicate = _ => true, |
|
@ -142,14 +141,12 @@ namespace Webhooks.API |
|
|
return services; |
|
|
return services; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public static IServiceCollection AddCustomMVC(this IServiceCollection services, IConfiguration configuration) |
|
|
|
|
|
|
|
|
public static IServiceCollection AddCustomRouting(this IServiceCollection services, IConfiguration configuration) |
|
|
{ |
|
|
{ |
|
|
services.AddMvc(options => |
|
|
|
|
|
|
|
|
services.AddControllers(options => |
|
|
{ |
|
|
{ |
|
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter)); |
|
|
options.Filters.Add(typeof(HttpGlobalExceptionFilter)); |
|
|
}) |
|
|
|
|
|
.SetCompatibilityVersion(CompatibilityVersion.Version_3_0) |
|
|
|
|
|
.AddControllersAsServices(); |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
services.AddCors(options => |
|
|
services.AddCors(options => |
|
|
{ |
|
|
{ |
|
@ -209,7 +206,7 @@ namespace Webhooks.API |
|
|
TokenUrl = new Uri($"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/token"), |
|
|
TokenUrl = new Uri($"{configuration.GetValue<string>("IdentityUrlExternal")}/connect/token"), |
|
|
Scopes = new Dictionary<string, string>() |
|
|
Scopes = new Dictionary<string, string>() |
|
|
{ |
|
|
{ |
|
|
{ "marketing", "Marketing API" } |
|
|
|
|
|
|
|
|
{ "webhooks", "Webhooks API" } |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|