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.
 
 
 

53 linhas
1.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Threading.Tasks;
  5. using Cap.Consistency.Infrastructure;
  6. using Microsoft.AspNetCore.Builder;
  7. using Microsoft.AspNetCore.Hosting;
  8. using Microsoft.EntityFrameworkCore;
  9. using Microsoft.Extensions.Configuration;
  10. using Microsoft.Extensions.DependencyInjection;
  11. using Microsoft.Extensions.Logging;
  12. namespace Sample.Kafka
  13. {
  14. public class Startup
  15. {
  16. public Startup(IHostingEnvironment env) {
  17. var builder = new ConfigurationBuilder()
  18. .SetBasePath(env.ContentRootPath)
  19. .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
  20. .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
  21. .AddEnvironmentVariables();
  22. Configuration = builder.Build();
  23. }
  24. public IConfigurationRoot Configuration { get; }
  25. // This method gets called by the runtime. Use this method to add services to the container.
  26. public void ConfigureServices(IServiceCollection services) {
  27. services.AddDbContext<AppDbContext>();
  28. services.AddConsistency()
  29. .AddEntityFrameworkStores<AppDbContext>()
  30. .AddKafka();
  31. // Add framework services.
  32. services.AddMvc();
  33. }
  34. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  35. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
  36. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  37. loggerFactory.AddDebug();
  38. app.UseMvc();
  39. app.UseConsistency();
  40. }
  41. }
  42. }