Startup.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System;
  2. using System.Collections.Generic;
  3. using Microsoft.AspNetCore.Builder;
  4. using Microsoft.AspNetCore.Hosting;
  5. using Microsoft.Extensions.DependencyInjection;
  6. using Microsoft.Extensions.Hosting;
  7. using VCommon.VAspNetCoreExample.VApp.Example;
  8. using VCommon.VOpenApi.VAspNetCore;
  9. using VCommon.VSwaggerUI;
  10. using VCommon.VSwaggerUI.VAspNetCore;
  11. namespace VCommon.VAspNetCoreExample
  12. {
  13. public class Startup
  14. {
  15. // This method gets called by the runtime. Use this method to add services to the container.
  16. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
  17. public void ConfigureServices(IServiceCollection services)
  18. {
  19. }
  20. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  21. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  22. {
  23. var dbg = false;
  24. if (env.IsDevelopment())
  25. {
  26. app.UseDeveloperExceptionPage();
  27. dbg = true;
  28. }
  29. app.UseSwaggerUiMiddleware(SwaggerUiResourceProvider.Version1);
  30. ApiMiddleware.Init(new Dictionary<string, Type>
  31. {
  32. { "Example", typeof(IExampleService) }
  33. },
  34. docGen: true, title: "Example API Set",
  35. isDebuggingEnabled: dbg);
  36. app.UseMiddleware<ApiMiddleware>();
  37. }
  38. }
  39. }