/
Airat
/
ASP.NET
Обзор
Документация
Войти
/
Airat
/
ASP.NET
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
Base/src/PromoCodeFactory.WebHost/Startup.cs
56 строк
2 KB
Алексей Ягур
Added Base homework
19 июл 2024, 22:15
19 июл 2024, 22:15
d9703a1
Код
Авторство
О чём код?
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; using PromoCodeFactory.Core.Abstractions.Repositories; using PromoCodeFactory.Core.Domain.Administration; using PromoCodeFactory.DataAccess.Data; using PromoCodeFactory.DataAccess.Repositories; namespace PromoCodeFactory.WebHost { public class Startup { public void ConfigureServices(IServiceCollection services) { services.AddControllers(); services.AddSingleton(typeof(IRepository<Employee>), (x) => new InMemoryRepository<Employee>(FakeDataFactory.Employees)); services.AddSingleton(typeof(IRepository<Role>), (x) => new InMemoryRepository<Role>(FakeDataFactory.Roles)); services.AddOpenApiDocument(options => { options.Title = "PromoCode Factory API Doc"; options.Version = "1.0"; }); } public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseHsts(); } app.UseOpenApi(); app.UseSwaggerUi(x => { x.DocExpansion = "list"; }); app.UseHttpsRedirection(); app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); } } }