Startup.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.AspNetCore.Mvc;
  4. using Microsoft.Extensions.Configuration;
  5. using Microsoft.Extensions.DependencyInjection;
  6. using Microsoft.Extensions.Hosting;
  7. using Microsoft.Extensions.Logging;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Threading.Tasks;
  12. namespace WebApplication2
  13. {
  14. public class Startup
  15. {
  16. public Startup(IConfiguration configuration)
  17. {
  18. Configuration = configuration;
  19. }
  20. public IConfiguration Configuration { get; }
  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.AddSwaggerDocument();
  26. }
  27. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  28. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  29. {
  30. if (env.IsDevelopment())
  31. {
  32. app.UseDeveloperExceptionPage();
  33. }
  34. app.UseRouting();
  35. app.UseAuthorization();
  36. app.UseOpenApi();
  37. app.UseSwaggerUi3();
  38. app.UseEndpoints(endpoints =>
  39. {
  40. endpoints.MapControllers();
  41. });
  42. }
  43. }
  44. }