You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

53 rivejä
1.8 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.AddConsistency()
  25. .AddEntityFrameworkStores<AppDbContext>()
  26. .AddRabbitMQ(x =>
  27. {
  28. x.HostName = "192.168.2.206";
  29. x.UserName = "admin";
  30. x.Password = "123123";
  31. })
  32. .AddKafka(x => x.Servers = "");
  33. // Add framework services.
  34. services.AddMvc();
  35. }
  36. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  37. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
  38. {
  39. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  40. loggerFactory.AddDebug();
  41. app.UseMvc();
  42. app.UseCap();
  43. }
  44. }
  45. }