陈哲 陈哲

陈哲 陈哲

  • NA
  • 2
  • 1.1k

how to store ocelot configuration in consul

Jun 20 2018 10:04 PM
Hi. I want to store configuration in consul following doc (http://ocelot.readthedocs.io/en/latest/features/configuration.html#store-configuration-in-consul) ; but i can't running successfully 
  1.  public void ConfigureServices(IServiceCollection services)  
  2.         {  
  3.             services.AddMvc();  
  4.   
  5.              services.AddOcelot().AddStoreOcelotConfigurationInConsul();  
  6.         }  
  7.   
  8. public async void Configure(IApplicationBuilder app, IHostingEnvironment env)  
  9.         {  
  10.             if (env.IsDevelopment())  
  11.             {  
  12.                 app.UseDeveloperExceptionPage();  
  13.             }  
  14.   
  15.             await app.UseOcelot();  
  16.   
  17.             // app.UseAuthentication();  
  18.   
  19.             app.UseMvc();  
  20.         }  
  21.   
  22.   
  23. Program.cs  
  24. public static IWebHost BuildWebHost(string[] args) =>  
  25.             WebHost.CreateDefaultBuilder(args)  
  26.                 .UseContentRoot(Directory.GetCurrentDirectory())  
  27.                 .ConfigureAppConfiguration((builderContext, config) =>  
  28.                 {  
  29.                     config  
  30.                        .SetBasePath(builderContext.HostingEnvironment.ContentRootPath)  
  31.                        .AddJsonFile("ocelot.json", optional: false, reloadOnChange: true)  
  32.                        .AddEnvironmentVariables();  
  33.                 })  
  34.                 .UseStartup<Startup>()  
  35.                 .Build();