mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-06-19 16:48:15 +08:00
#296 renamed configuration.json to ocelot.json in preparation
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
Configuration
|
||||
============
|
||||
|
||||
An example configuration can be found `here <https://github.com/TomPallister/Ocelot/blob/develop/test/Ocelot.ManualTest/configuration.json>`_.
|
||||
An example configuration can be found `here <https://github.com/TomPallister/Ocelot/blob/develop/test/Ocelot.ManualTest/ocelot.json>`_.
|
||||
There are two sections to the configuration. An array of ReRoutes and a GlobalConfiguration.
|
||||
The ReRoutes are the objects that tell Ocelot how to treat an upstream request. The Global
|
||||
configuration is a bit hacky and allows overrides of ReRoute specific settings. It's useful
|
||||
@ -99,12 +99,12 @@ to you
|
||||
.SetBasePath(hostingContext.HostingEnvironment.ContentRootPath)
|
||||
.AddJsonFile("appsettings.json", true, true)
|
||||
.AddJsonFile($"appsettings.{hostingContext.HostingEnvironment.EnvironmentName}.json", true, true)
|
||||
.AddJsonFile("configuration.json")
|
||||
.AddJsonFile("ocelot.json")
|
||||
.AddJsonFile($"configuration.{hostingContext.HostingEnvironment.EnvironmentName}.json")
|
||||
.AddEnvironmentVariables();
|
||||
})
|
||||
|
||||
Ocelot should now use the environment specific configuration and fall back to configuration.json if there isnt one.
|
||||
Ocelot should now use the environment specific configuration and fall back to ocelot.json if there isnt one.
|
||||
|
||||
You also need to set the corresponding environment variable which is ASPNETCORE_ENVIRONMENT. More info on this can be found in the `asp.net core docs <https://docs.microsoft.com/en-us/aspnet/core/fundamentals/environments>`_.
|
||||
|
||||
@ -119,7 +119,7 @@ If you add the following when you register your services Ocelot will attempt to
|
||||
.AddOcelot()
|
||||
.AddStoreOcelotConfigurationInConsul();
|
||||
|
||||
You also need to add the following to your configuration.json. This is how Ocelot
|
||||
You also need to add the following to your ocelot.json. This is how Ocelot
|
||||
finds your Consul agent and interacts to load and store the configuration from Consul.
|
||||
|
||||
.. code-block:: json
|
||||
|
@ -40,7 +40,7 @@ Or transient as below...
|
||||
.AddTransientDelegatingHandler<FakeHandlerTwo>()
|
||||
|
||||
Both of these Add methods have a default parameter called global which is set to false. If it is false then the intent of
|
||||
the DelegatingHandler is to be applied to specific ReRoutes via configuration.json (more on that later). If it is set to true
|
||||
the DelegatingHandler is to be applied to specific ReRoutes via ocelot.json (more on that later). If it is set to true
|
||||
then it becomes a global handler and will be applied to all ReRoutes.
|
||||
|
||||
e.g.
|
||||
@ -58,7 +58,7 @@ Or transient as below...
|
||||
.AddTransientDelegatingHandler<FakeHandler>(true)
|
||||
|
||||
Finally if you want ReRoute specific DelegatingHandlers or to order your specific and / or global (more on this later) DelegatingHandlers
|
||||
then you must add the following json to the specific ReRoute in configuration.json. The names in the array must match the class names of your
|
||||
then you must add the following json to the specific ReRoute in ocelot.json. The names in the array must match the class names of your
|
||||
DelegatingHandlers for Ocelot to match them together.
|
||||
|
||||
.. code-block:: json
|
||||
@ -70,8 +70,8 @@ DelegatingHandlers for Ocelot to match them together.
|
||||
|
||||
You can have as many DelegatingHandlers as you want and they are run in the following order:
|
||||
|
||||
1. Any globals that are left in the order they were added to services and are not in the DelegatingHandlers array from configuration.json.
|
||||
2. Any non global DelegatingHandlers plus any globals that were in the DelegatingHandlers array from configuration.json ordered as they are in the DelegatingHandlers array.
|
||||
1. Any globals that are left in the order they were added to services and are not in the DelegatingHandlers array from ocelot.json.
|
||||
2. Any non global DelegatingHandlers plus any globals that were in the DelegatingHandlers array from ocelot.json ordered as they are in the DelegatingHandlers array.
|
||||
3. Tracing DelegatingHandler if enabled (see tracing docs).
|
||||
4. QoS DelegatingHandler if enabled (see QoS docs).
|
||||
5. The HttpClient sends the HttpRequestMessage.
|
||||
|
@ -9,7 +9,7 @@ Add to Response
|
||||
This feature was requested in `GitHub #280 <https://github.com/TomPallister/Ocelot/issues/280>`_. I have only implemented
|
||||
for responses but could add for requests in the future.
|
||||
|
||||
If you want to add a header to your downstream response please add the following to a ReRoute in configuration.json..
|
||||
If you want to add a header to your downstream response please add the following to a ReRoute in ocelot.json..
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
@ -41,7 +41,7 @@ The key is "Test" and the value is "http://www.bbc.co.uk/, http://ocelot.com/".
|
||||
Pre Downstream Request
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Add the following to a ReRoute in configuration.json in order to replace http://www.bbc.co.uk/ with http://ocelot.com/. This header will be changed before the request downstream and will be sent to the downstream server.
|
||||
Add the following to a ReRoute in ocelot.json in order to replace http://www.bbc.co.uk/ with http://ocelot.com/. This header will be changed before the request downstream and will be sent to the downstream server.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
@ -52,7 +52,7 @@ Add the following to a ReRoute in configuration.json in order to replace http://
|
||||
Post Downstream Request
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Add the following to a ReRoute in configuration.json in order to replace http://www.bbc.co.uk/ with http://ocelot.com/. This transformation will take place after Ocelot has received the response from the downstream service.
|
||||
Add the following to a ReRoute in ocelot.json in order to replace http://www.bbc.co.uk/ with http://ocelot.com/. This transformation will take place after Ocelot has received the response from the downstream service.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
@ -16,7 +16,7 @@ You must choose in your configuration which load balancer to use.
|
||||
Configuration
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
The following shows how to set up multiple downstream services for a ReRoute using configuration.json and then select the LeadConnection load balancer. This is the simplest way to get load balancing set up.
|
||||
The following shows how to set up multiple downstream services for a ReRoute using ocelot.json and then select the LeadConnection load balancer. This is the simplest way to get load balancing set up.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
@ -23,7 +23,7 @@ Period - This value specifies the period, such as 1s, 5m, 1h,1d and so on.
|
||||
PeriodTimespan - This value specifies that we can retry after a certain number of seconds.
|
||||
Limit - This value specifies the maximum number of requests that a client can make in a defined period.
|
||||
|
||||
You can also set the following in the GlobalConfiguration part of configuration.json
|
||||
You can also set the following in the GlobalConfiguration part of ocelot.json
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
@ -7,7 +7,7 @@ architecture with Ocelot.
|
||||
|
||||
This feature was requested as part of `Issue 79 <https://github.com/TomPallister/Ocelot/pull/79>`_ and further improvements were made as part of `Issue 298 <https://github.com/TomPallister/Ocelot/issue/298>`_.
|
||||
|
||||
In order to set this up you must do something like the following in your configuration.json. Here we have specified two normal ReRoutes and each one has a Key property.
|
||||
In order to set this up you must do something like the following in your ocelot.json. Here we have specified two normal ReRoutes and each one has a Key property.
|
||||
We then specify an Aggregate that composes the two ReRoutes using their keys in the ReRouteKeys list and says then we have the UpstreamPathTemplate which works like a normal ReRoute.
|
||||
Obviously you cannot have duplicate UpstreamPathTemplates between ReRoutes and Aggregates. You can use all of Ocelot's normal ReRoute options apart from RequestIdKey (explained in gotchas below).
|
||||
|
||||
@ -17,7 +17,7 @@ Advanced register your own Aggregators
|
||||
Ocelot started with just the basic request aggregation and since then we have added a more advanced method that let's the user take in the responses from the
|
||||
downstream services and then aggregate them into a response object.
|
||||
|
||||
The configuration.json setup is pretty much the same as the basic aggregation approach apart from you need to add an Aggregator property like below.
|
||||
The ocelot.json setup is pretty much the same as the basic aggregation approach apart from you need to add an Aggregator property like below.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
@ -12,7 +12,7 @@ In order to use the reques tid feature you have two options.
|
||||
|
||||
*Global*
|
||||
|
||||
In your configuration.json set the following in the GlobalConfiguration section. This will be used for all requests into Ocelot.
|
||||
In your ocelot.json set the following in the GlobalConfiguration section. This will be used for all requests into Ocelot.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
@ -24,7 +24,7 @@ I reccomend using the GlobalConfiguration unless you really need it to be ReRout
|
||||
|
||||
*ReRoute*
|
||||
|
||||
If you want to override this for a specific ReRoute add the following to configuration.json for the specific ReRoute.
|
||||
If you want to override this for a specific ReRoute add the following to ocelot.json for the specific ReRoute.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
@ -145,9 +145,9 @@ Priority
|
||||
^^^^^^^^
|
||||
|
||||
In `Issue 270 <https://github.com/TomPallister/Ocelot/pull/270>`_ I finally decided to expose the ReRoute priority in
|
||||
configuration.json. This means you can decide in what order you want your ReRoutes to match the Upstream HttpRequest.
|
||||
ocelot.json. This means you can decide in what order you want your ReRoutes to match the Upstream HttpRequest.
|
||||
|
||||
In order to get this working add the following to a ReRoute in configuration.json, 0 is just an example value here but will explain below.
|
||||
In order to get this working add the following to a ReRoute in ocelot.json, 0 is just an example value here but will explain below.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
@ -20,7 +20,7 @@ In your ConfigureServices method
|
||||
option.Service = "Ocelot";
|
||||
});
|
||||
|
||||
Then in your configuration.json add the following to the ReRoute you want to trace..
|
||||
Then in your ocelot.json add the following to the ReRoute you want to trace..
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
@ -15,7 +15,7 @@ In your Configure method you need to tell your application to use WebSockets.
|
||||
app.UseOcelot().Wait();
|
||||
})
|
||||
|
||||
Then in your configuration.json add the following to proxy a ReRoute using websockets.
|
||||
Then in your ocelot.json add the following to proxy a ReRoute using websockets.
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
Reference in New Issue
Block a user