2021-05-29 17:02:16 +00:00
|
|
|
using System;
|
2021-05-28 20:52:56 +00:00
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
|
|
using Microsoft.AspNetCore.Hosting;
|
|
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
using Microsoft.Extensions.Logging;
|
2021-05-29 17:02:16 +00:00
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
using Retroactiune.Services;
|
|
|
|
using Retroactiune.Settings;
|
2021-05-28 20:52:56 +00:00
|
|
|
|
|
|
|
namespace Retroactiune
|
|
|
|
{
|
|
|
|
public class Startup
|
|
|
|
{
|
|
|
|
public Startup(IConfiguration configuration)
|
|
|
|
{
|
|
|
|
Configuration = configuration;
|
|
|
|
}
|
|
|
|
|
|
|
|
private IConfiguration Configuration { get; }
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
|
|
public void ConfigureServices(IServiceCollection services)
|
|
|
|
{
|
2021-05-29 17:02:16 +00:00
|
|
|
// Database Configuration
|
|
|
|
services.Configure<RetroactiuneDbSettings>(Configuration.GetSection(nameof(RetroactiuneDbSettings)));
|
|
|
|
services.AddSingleton<IMongoDbSettings>(sp =>
|
|
|
|
sp.GetRequiredService<IOptions<RetroactiuneDbSettings>>().Value);
|
|
|
|
|
|
|
|
services.AddAutoMapper(AppDomain.CurrentDomain.GetAssemblies());
|
|
|
|
|
|
|
|
|
|
|
|
// Services
|
2021-05-29 18:12:36 +00:00
|
|
|
services.AddSingleton<IFeedbackReceiverService, FeedbackReceiverService>();
|
2021-05-29 17:02:16 +00:00
|
|
|
|
|
|
|
// WebAPI
|
2021-05-28 20:52:56 +00:00
|
|
|
services.AddControllers();
|
|
|
|
services.AddSwaggerGen();
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILogger<Startup> logger)
|
|
|
|
{
|
|
|
|
if (env.IsDevelopment())
|
|
|
|
{
|
|
|
|
app.UseDeveloperExceptionPage();
|
|
|
|
}
|
2021-05-29 17:02:16 +00:00
|
|
|
|
2021-05-28 20:52:56 +00:00
|
|
|
app.UseSwagger();
|
|
|
|
app.UseSwaggerUI(c =>
|
|
|
|
{
|
|
|
|
c.SwaggerEndpoint("/swagger/v1/swagger.json", "Retroactiune API");
|
|
|
|
c.RoutePrefix = "";
|
|
|
|
});
|
2021-05-29 17:02:16 +00:00
|
|
|
|
2021-05-28 20:52:56 +00:00
|
|
|
app.UseHttpsRedirection();
|
|
|
|
|
|
|
|
app.UseRouting();
|
|
|
|
|
|
|
|
app.UseAuthorization();
|
|
|
|
|
|
|
|
app.UseEndpoints(endpoints => { endpoints.MapControllers(); });
|
2021-05-29 17:02:16 +00:00
|
|
|
|
2021-05-28 20:52:56 +00:00
|
|
|
logger.LogInformation("Running");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|