Startup.cs 1.7 KB

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