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.
 
 
 

44 lines
1.6 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. var builder = new ConfigurationBuilder()
  12. .SetBasePath(env.ContentRootPath)
  13. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  14. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  15. .AddEnvironmentVariables();
  16. Configuration = builder.Build();
  17. }
  18. public IConfigurationRoot Configuration { get; }
  19. // This method gets called by the runtime. Use this method to add services to the container.
  20. public void ConfigureServices(IServiceCollection services) {
  21. services.AddDbContext<AppDbContext>();
  22. services.AddConsistency()
  23. .AddEntityFrameworkStores<AppDbContext>()
  24. .AddKafka();
  25. // Add framework services.
  26. services.AddMvc();
  27. }
  28. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  29. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
  30. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  31. loggerFactory.AddDebug();
  32. app.UseMvc();
  33. app.UseConsistency();
  34. }
  35. }
  36. }