52 lines
1.5 KiB
C#
52 lines
1.5 KiB
C#
using API.Extensions;
|
|
using API.Helpers;
|
|
using API.Middleware;
|
|
using Infrastructure.Data;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace API
|
|
{
|
|
public class Startup
|
|
{
|
|
private readonly IConfiguration _config;
|
|
public Startup(IConfiguration config)
|
|
{
|
|
_config = config;
|
|
}
|
|
|
|
|
|
// This method gets called by the runtime. Use this method to add services to the container.
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
|
|
services.AddControllers();
|
|
services.AddApplicationServices();
|
|
services.AddSwaggerDocumentation();
|
|
services.AddDbContext<StoreContext>(x => x.UseSqlite(_config.GetConnectionString("DefaultConnection")));
|
|
services.AddAutoMapper(typeof(MappingProfiles));
|
|
|
|
}
|
|
|
|
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
app.UseMiddleware<ExceptionMiddleware>();
|
|
|
|
app.UseStatusCodePagesWithReExecute("/errors/{0}");
|
|
|
|
app.UseHttpsRedirection();
|
|
|
|
app.UseRouting();
|
|
app.UseStaticFiles();
|
|
|
|
app.UseAuthorization();
|
|
app.UseSwaggerDocumentation();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapControllers();
|
|
});
|
|
}
|
|
}
|
|
}
|