2020-10-29 12:17:09 +02:00
|
|
|
using System.Diagnostics.CodeAnalysis;
|
2020-11-01 22:25:48 +02:00
|
|
|
using Hangfire;
|
2020-10-26 21:24:40 +02:00
|
|
|
using MalwareMultiScan.Api.Extensions;
|
2020-11-01 22:25:48 +02:00
|
|
|
using MalwareMultiScan.Api.Services;
|
2020-10-29 12:17:09 +02:00
|
|
|
using MalwareMultiScan.Api.Services.Interfaces;
|
2020-11-01 22:25:48 +02:00
|
|
|
using MalwareMultiScan.Shared.Extensions;
|
|
|
|
using MalwareMultiScan.Shared.Services.Interfaces;
|
2020-10-22 22:20:21 +03:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
2020-11-01 22:25:48 +02:00
|
|
|
using Microsoft.Extensions.Hosting;
|
2020-10-22 22:20:21 +03:00
|
|
|
|
|
|
|
namespace MalwareMultiScan.Api
|
|
|
|
{
|
2020-11-02 11:00:24 +02:00
|
|
|
[ExcludeFromCodeCoverage]
|
2020-10-29 12:17:09 +02:00
|
|
|
internal class Startup
|
2020-10-22 22:20:21 +03:00
|
|
|
{
|
2020-10-23 11:11:19 +03:00
|
|
|
private readonly IConfiguration _configuration;
|
|
|
|
|
2020-10-22 22:20:21 +03:00
|
|
|
public Startup(IConfiguration configuration)
|
|
|
|
{
|
2020-10-23 11:11:19 +03:00
|
|
|
_configuration = configuration;
|
2020-10-22 22:20:21 +03:00
|
|
|
}
|
2020-10-26 17:06:29 +02:00
|
|
|
|
2020-10-22 22:20:21 +03:00
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
{
|
2020-10-26 21:24:40 +02:00
|
|
|
services.AddDockerForwardedHeadersOptions();
|
2020-10-29 16:09:56 +02:00
|
|
|
|
2020-11-01 22:25:48 +02:00
|
|
|
services.AddConsul(_configuration);
|
2020-10-26 21:24:40 +02:00
|
|
|
services.AddMongoDb(_configuration);
|
2020-11-01 22:25:48 +02:00
|
|
|
services.AddHangfire(_configuration);
|
2020-11-02 11:39:12 +02:00
|
|
|
|
2020-10-29 12:17:09 +02:00
|
|
|
services.AddSingleton<IScanResultService, ScanResultService>();
|
2020-11-01 22:25:48 +02:00
|
|
|
services.AddSingleton<IScanResultJob, ScanResultJob>();
|
2020-11-02 11:39:12 +02:00
|
|
|
|
2020-10-22 22:20:21 +03:00
|
|
|
services.AddControllers();
|
2020-10-30 11:20:08 +02:00
|
|
|
services.AddHttpClient();
|
2020-10-22 22:20:21 +03:00
|
|
|
}
|
|
|
|
|
2020-11-01 22:25:48 +02:00
|
|
|
public void Configure(IApplicationBuilder app, IHostEnvironment hostEnvironment)
|
2020-10-22 22:20:21 +03:00
|
|
|
{
|
|
|
|
app.UseRouting();
|
2020-10-26 16:20:47 +02:00
|
|
|
app.UseEndpoints(endpoints => endpoints.MapControllers());
|
2020-11-02 11:39:12 +02:00
|
|
|
|
2020-11-01 22:25:48 +02:00
|
|
|
app.UseForwardedHeaders();
|
2020-11-02 11:39:12 +02:00
|
|
|
|
2020-11-01 22:25:48 +02:00
|
|
|
if (hostEnvironment.IsDevelopment())
|
|
|
|
app.UseHangfireDashboard();
|
2020-10-22 22:20:21 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|