Startup.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. using XYY.Service.Standard.RegionService;
  13. namespace XYY.Api.Customer
  14. {
  15. public class Startup
  16. {
  17. readonly string MyAllowSpecificOrigins = "_myAllowSpecificOrigins";//Ãû×ÖËæ±ãÆð
  18. public Startup(IConfiguration configuration)
  19. {
  20. Configuration = configuration;
  21. }
  22. public IConfiguration Configuration { get; }
  23. // This method gets called by the runtime. Use this method to add services to the container.
  24. public void ConfigureServices(IServiceCollection services)
  25. {
  26. services.AddXYYService(new ServiceOption
  27. {
  28. USEDBTransferAsMVC = true,
  29. CacheType = DistributedCacheType.Redis,
  30. SqlServiceConnection = Configuration[DefaultConfig.SqlServiceConnectionKey],
  31. RedisConnection = Configuration[DefaultConfig.RedisConnectionKey],
  32. UseRabbit = true
  33. }, Configuration);
  34. services.AddControllers();
  35. //services.AddSwaggerGen(c =>
  36. //{
  37. // c.SwaggerDoc("v1", new OpenApiInfo { Title = "XYY.Api.Customer", Version = "v1" });
  38. //});
  39. }
  40. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  41. public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
  42. {
  43. if (env.IsDevelopment())
  44. {
  45. app.UseDeveloperExceptionPage();
  46. }
  47. app.UseStatusCodePages();
  48. app.UseRouting();
  49. app.UseCors(MyAllowSpecificOrigins);
  50. app.UseEndpoints(endpoints =>
  51. {
  52. endpoints.MapControllers();
  53. });
  54. }
  55. }
  56. }