mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 07:18:16 +08:00
Feature/docs (#165)
* initial readthedocs commit * docs moved to sphinx / rst / read the docs
This commit is contained in:
4
docs/introduction/bigpicture.rst
Normal file
4
docs/introduction/bigpicture.rst
Normal file
@ -0,0 +1,4 @@
|
||||
Big Picture
|
||||
===========
|
||||
|
||||
Coming soon...
|
5
docs/introduction/contributing.rst
Normal file
5
docs/introduction/contributing.rst
Normal file
@ -0,0 +1,5 @@
|
||||
Contributing
|
||||
============
|
||||
|
||||
Pull requests, issues and commentary welcome! No special process just create a request and get in
|
||||
touch either via gitter or create an issue.
|
100
docs/introduction/gettingstarted.rst
Normal file
100
docs/introduction/gettingstarted.rst
Normal file
@ -0,0 +1,100 @@
|
||||
Getting Started
|
||||
===============
|
||||
|
||||
Ocelot is designed to work with ASP.NET core only and is currently
|
||||
built to netcoreapp2.0 `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 NuGet package**
|
||||
|
||||
Install Ocelot and it's dependecies using nuget. You will need to create a netcoreapp2.0 projct and bring the package into it. Then follow the Startup below and :doc:`../features/configuration` sections
|
||||
to get up and running.
|
||||
|
||||
``Install-Package Ocelot``
|
||||
|
||||
All versions can be found `here <https://www.nuget.org/packages/Ocelot/>`_.
|
||||
|
||||
**Configuration**
|
||||
|
||||
The following is a very basic configuration.json. It won't do anything but should get Ocelot starting.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"ReRoutes": [],
|
||||
"GlobalConfiguration": {}
|
||||
}
|
||||
|
||||
**Program**
|
||||
|
||||
Then in your Program.cs you will want to have the following. This can be changed if you
|
||||
don't wan't to use the default url e.g. UseUrls(someUrls) and should work as long as you keep the WebHostBuilder registration.
|
||||
|
||||
.. code-block:: csharp
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
IWebHostBuilder builder = new WebHostBuilder();
|
||||
|
||||
builder.ConfigureServices(s => {
|
||||
s.AddSingleton(builder);
|
||||
});
|
||||
|
||||
builder.UseKestrel()
|
||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||
.UseStartup<Startup>();
|
||||
|
||||
var host = builder.Build();
|
||||
|
||||
host.Run();
|
||||
}
|
||||
}
|
||||
|
||||
Sadly we need to inject the IWebHostBuilder interface to get the applications scheme, url and port later. I cannot find a better way of doing this at the moment without setting this in a static or some kind of config.
|
||||
|
||||
**Startup**
|
||||
|
||||
An example startup using a json file for configuration can be seen below.
|
||||
Currently this is the only way to get configuration into Ocelot.
|
||||
|
||||
.. code-block:: csharp
|
||||
|
||||
public class Startup
|
||||
{
|
||||
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)
|
||||
.AddJsonFile("configuration.json")
|
||||
.AddEnvironmentVariables();
|
||||
|
||||
Configuration = builder.Build();
|
||||
}
|
||||
|
||||
public IConfigurationRoot Configuration { get; }
|
||||
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
services.AddOcelot(Configuration)
|
||||
.AddCacheManager(x => {
|
||||
x.WithMicrosoftLogging(log =>
|
||||
{
|
||||
log.AddConsole(LogLevel.Debug);
|
||||
})
|
||||
.WithDictionaryHandle();
|
||||
});;
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
|
||||
{
|
||||
loggerFactory.AddConsole(Configuration.GetSection("Logging"));
|
||||
|
||||
app.UseOcelot().Wait();
|
||||
}
|
||||
}
|
||||
|
||||
This is pretty much all you need to get going.......more to come!
|
8
docs/introduction/notsupported.rst
Normal file
8
docs/introduction/notsupported.rst
Normal file
@ -0,0 +1,8 @@
|
||||
Not Supported
|
||||
=============
|
||||
|
||||
Ocelot does not support...
|
||||
|
||||
* Chunked Encoding - Ocelot will always get the body size and return Content-Length header. Sorry if this doesn't work for your use case!
|
||||
|
||||
* Fowarding a host header - The host header that you send to Ocelot will not be forwarded to the downstream service. Obviously this would break everything :(
|
Reference in New Issue
Block a user