50 lines
1.6 KiB
C#
Raw Permalink Normal View History

2020-10-29 12:17:09 +02:00
using System.Diagnostics.CodeAnalysis;
using MalwareMultiScan.Api.Extensions;
2020-10-29 12:17:09 +02:00
using MalwareMultiScan.Api.Services.Implementations;
using MalwareMultiScan.Api.Services.Interfaces;
2020-10-29 16:09:56 +02:00
using MalwareMultiScan.Backends.Extensions;
2020-10-22 22:20:21 +03:00
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Server.Kestrel.Core;
2020-10-22 22:20:21 +03:00
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
namespace MalwareMultiScan.Api
{
2020-10-29 12:17:09 +02:00
[ExcludeFromCodeCoverage]
internal class Startup
2020-10-22 22:20:21 +03:00
{
private readonly IConfiguration _configuration;
2020-10-22 22:20:21 +03:00
public Startup(IConfiguration configuration)
{
_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)
{
services.AddDockerForwardedHeadersOptions();
2020-10-29 16:09:56 +02:00
services.Configure<KestrelServerOptions>(options =>
{
options.Limits.MaxRequestBodySize = _configuration.GetValue<int>("MaxFileSize");
});
services.AddMongoDb(_configuration);
services.AddRabbitMq(_configuration);
2020-10-29 12:17:09 +02:00
services.AddSingleton<IScanBackendService, ScanBackendService>();
services.AddSingleton<IScanResultService, ScanResultService>();
2020-10-26 17:06:29 +02:00
2020-10-22 22:20:21 +03:00
services.AddControllers();
2020-10-26 17:06:29 +02:00
services.AddHostedService<ReceiverHostedService>();
2020-10-22 22:20:21 +03:00
}
public void Configure(IApplicationBuilder app)
2020-10-22 22:20:21 +03:00
{
app.UseRouting();
app.UseForwardedHeaders();
app.UseEndpoints(endpoints => endpoints.MapControllers());
2020-10-22 22:20:21 +03:00
}
}
}