Nenhuma descrição

Startup.cs 2.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Backend.API.Config;
  2. using Backend.ApplicationCore.Mapper;
  3. using Backend.Persistence.Config;
  4. using Microsoft.AspNetCore.Builder;
  5. using Microsoft.AspNetCore.Hosting;
  6. using Microsoft.Extensions.Configuration;
  7. using Microsoft.Extensions.DependencyInjection;
  8. using Microsoft.Extensions.Hosting;
  9. using System;
  10. namespace Backend.API
  11. {
  12. public class Startup
  13. {
  14. private readonly IConfiguration _configuration = null;
  15. private readonly IHostEnvironment _appEnvironment = null;
  16. public Startup(IConfiguration configuration, IHostEnvironment appEnvironment)
  17. {
  18. _configuration = configuration;
  19. _appEnvironment = appEnvironment;
  20. }
  21. // This method gets called by the runtime. Use this method to add services to the container.
  22. public void ConfigureServices(IServiceCollection services)
  23. {
  24. services.AddControllers();
  25. services.AddOptions();
  26. services.AddDependencyInjectionService();
  27. services.AddDataDependencyInjectionRepository();
  28. services.AddMediaRHandlerDependency();
  29. services.AddAutoMapperConfig();
  30. services.AddSwaggerDocumentation();
  31. AddDatabase(services);
  32. }
  33. protected virtual void AddDatabase(IServiceCollection services)
  34. {
  35. if (services != null)
  36. {
  37. services.AddDatabaseModule(_configuration);
  38. }
  39. }
  40. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  41. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IServiceProvider serviceProvider)
  42. {
  43. if (env.IsDevelopment())
  44. {
  45. app.UseDeveloperExceptionPage();
  46. }
  47. app.UseRouting();
  48. app.UseAuthorization();
  49. app.UseEndpoints(endpoints =>
  50. {
  51. endpoints.MapControllers();
  52. });
  53. app.UseApplicationDatabase(serviceProvider);
  54. app.UseSwaggerDocumentation();
  55. }
  56. }
  57. }

Powered by TurnKey Linux.