Startup.cs 1.5 KB

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