diff --git a/README.md b/README.md index c6b1fdd1..2e652f16 100644 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ to handle the IdentityServer reference tokens. We would rather use the IdentityServer code that already exists to do this. -# How to use +# How to install Ocelot is designed to work with ASP.NET core only and is currently built to .NET Standard 1.4 [this](https://docs.microsoft.com/en-us/dotnet/articles/standard/library) documentation may prove helpful when working out if Ocelot would be suitable for you. -Install Ocelot and it's dependecies using nuget. +Install Ocelot and it's dependecies using nuget. At the moment all we have is the pre version. Once we have something working in a half decent way we will drop a version. `Install-Package Ocelot -Pre` @@ -31,6 +31,50 @@ All versions can be found [here](https://www.nuget.org/packages/Ocelot/) # Configuration -An example configuration can be found [here](https://github.com/TomPallister/Ocelot/blob/develop/test/Ocelot.ManualTest/configuration.yaml ) +## Startup + +An example startup using a yaml file for configuration can be seen below. Currently this is the only way to get configuration into Ocelot. + +` +public class Startup + { + public IConfigurationRoot Configuration { get; } + + public Startup(IHostingEnvironment env) + { + var builder = new ConfigurationBuilder() + .SetBasePath(env.ContentRootPath) + .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true) + .AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true) + .AddYamlFile("configuration.yaml") + .AddEnvironmentVariables(); + + Configuration = builder.Build(); + } + // This method gets called by the runtime. Use this method to add services to the container. + // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940 + public void ConfigureServices(IServiceCollection services) + { + services.AddOcelotYamlConfiguration(Configuration); + services.AddOcelot(); + } + + // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. + public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) + { + loggerFactory.AddConsole(); + + if (env.IsDevelopment()) + { + app.UseDeveloperExceptionPage(); + } + app.UseOcelot(); + } + } +` + +An example configuration can be found [here](https://github.com/TomPallister/Ocelot/blob/develop/test/Ocelot.ManualTest/configuration.yaml) + +This is pretty much all you need to get going.......more to come!