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.

Startup.cs 1.6 KiB

7 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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.Extensions.Configuration;
  9. using Microsoft.Extensions.DependencyInjection;
  10. using Microsoft.Extensions.Logging;
  11. using Sample.Kafka.Entity;
  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. // Add framework services.
  28. services.AddMvc();
  29. services.AddConsistency<ConsistencyMessage>();
  30. }
  31. // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
  32. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) {
  33. loggerFactory.AddConsole(Configuration.GetSection("Logging"));
  34. loggerFactory.AddDebug();
  35. app.UseMvc();
  36. app.UseConsistency();
  37. }
  38. }
  39. }