Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 

53 rader
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<ConsistencyMessage>()
  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. }