mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-24 06:52:49 +08:00

* hacking around to work out why logging and request id isnt working * pass request id into logger so it can be structured, removed a bunch of debug logging we dont need because diagnostic trace gets it * changed config dependency * always have tracing available * made it so we dont need to pass config into services.AddOcelot anymore with .net core 2.0 * add test * lots of changes relating to logging and request ids, also updated documentation * fixed failing test i missed
53 lines
1.7 KiB
C#
53 lines
1.7 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Logging;
|
|
using Newtonsoft.Json;
|
|
using Ocelot.DependencyInjection;
|
|
using Ocelot.Middleware;
|
|
using Ocelot.Raft;
|
|
using Rafty.Concensus;
|
|
using Rafty.FiniteStateMachine;
|
|
using Rafty.Infrastructure;
|
|
using Rafty.Log;
|
|
using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;
|
|
|
|
namespace Ocelot.IntegrationTests
|
|
{
|
|
public class RaftStartup
|
|
{
|
|
public RaftStartup(IHostingEnvironment env)
|
|
{
|
|
var builder = new ConfigurationBuilder()
|
|
.SetBasePath(env.ContentRootPath)
|
|
.AddJsonFile("appsettings.json", optional: true, reloadOnChange: true)
|
|
.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true)
|
|
.AddJsonFile("peers.json", optional: true, reloadOnChange: true)
|
|
.AddJsonFile("configuration.json")
|
|
.AddEnvironmentVariables();
|
|
|
|
Configuration = builder.Build();
|
|
}
|
|
|
|
public IConfiguration Configuration { get; }
|
|
|
|
public virtual void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services
|
|
.AddOcelot(Configuration)
|
|
.AddAdministration("/administration", "secret")
|
|
.AddRafty();
|
|
}
|
|
|
|
public virtual void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
|
{
|
|
app.UseOcelot().Wait();
|
|
}
|
|
}
|
|
}
|