Created
March 17, 2022 14:20
-
-
Save theilgaz/f369b7c33059981bd209db79aa3e6467 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace API.Extensions | |
{ | |
public static class ApplicationServiceExtensions | |
{ | |
public static IServiceCollection AddApplicationServices(this IServiceCollection services, IConfiguration config) | |
{ | |
services.AddSwaggerGen(c => | |
{ | |
c.SwaggerDoc("v1", new OpenApiInfo { Title = "WebAPIv5", Version = "v1" }); | |
}); | |
services.AddDbContext<DataContext>(opt => | |
{ | |
opt.UseSqlite(config.GetConnectionString("DefaultConnection")); | |
}); | |
services.AddCors(opt => | |
{ | |
opt.AddPolicy("CorsPolicy", policy => | |
{ | |
policy.WithHeaders("Access-Control-Allow-Origin: *"); | |
}); | |
}); | |
services.AddMediatR(typeof(List.Handler).Assembly); | |
services.AddAutoMapper(typeof(MappingProfiles).Assembly); | |
return services; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment