Startup.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Hosting;
  6. namespace ServiceCenter.WebApi
  7. {
  8. public class Startup
  9. {
  10. public Startup(IConfiguration configuration)
  11. {
  12. Configuration = configuration;
  13. }
  14. public IConfiguration Configuration { get; }
  15. // This method gets called by the runtime. Use this method to add services to the container.
  16. public void ConfigureServices(IServiceCollection services)
  17. {
  18. services.AddControllers();
  19. //services.AddSwaggerGen(c =>
  20. //{
  21. // c.SwaggerDoc("v1", new OpenApiInfo { Title = "WCSAPI", Version = "v1" });
  22. //});
  23. }
  24. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  25. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  26. {
  27. if (env.IsDevelopment())
  28. {
  29. app.UseDeveloperExceptionPage();
  30. //app.UseSwagger();
  31. //app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "WebApplication1 v1"));
  32. }
  33. app.UseHttpsRedirection();
  34. app.UseRouting();
  35. app.UseAuthorization();
  36. app.UseEndpoints(endpoints =>
  37. {
  38. endpoints.MapControllers();
  39. });
  40. }
  41. }
  42. }