Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 

50 linhas
1.7 KiB

  1. using Microsoft.AspNetCore.Builder;
  2. using Microsoft.AspNetCore.Hosting;
  3. using Microsoft.Extensions.Configuration;
  4. using Microsoft.Extensions.DependencyInjection;
  5. using Microsoft.Extensions.Logging;
  6. namespace Sample.Kafka
  7. {
  8. public class Startup
  9. {
  10. public Startup(IHostingEnvironment env)
  11. {
  12. var builder = new ConfigurationBuilder()
  13. .SetBasePath(env.ContentRootPath)
  14. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  15. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  16. .AddEnvironmentVariables();
  17. Configuration = builder.Build();
  18. }
  19. public IConfigurationRoot Configuration { get; }
  20. // This method gets called by the runtime. Use this method to add services to the container.
  21. public void ConfigureServices(IServiceCollection services)
  22. {
  23. services.AddDbContext<AppDbContext>();
  24. services.AddCap(x =>
  25. {
  26. x.UseEntityFramework<AppDbContext>();
  27. //x.UseSqlServer("Server=DESKTOP-M9R8T31;Initial Catalog=Test;User Id=sa;Password=P@ssw0rd;MultipleActiveResultSets=True");
  28. x.UseKafka("localhost:9092");
  29. });
  30. // Add framework services.
  31. services.AddMvc();
  32. }
  33. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  34. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  35. {
  36. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  37. loggerFactory.AddDebug();
  38. app.UseMvc();
  39. app.UseCap();
  40. }
  41. }
  42. }