You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/administration.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -146,4 +146,4 @@ The region is whatever you set against the **Region** field in the `FileCacheOpt
146
146
147
147
""""
148
148
149
-
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to DI container. You could call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of :doc:`../features/dependencyinjection` feature.
149
+
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to the DI container. You can call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of the:doc:`../features/dependencyinjection` feature.
Copy file name to clipboardExpand all lines: docs/features/qualityofservice.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -142,7 +142,7 @@ And finally, if you want to define your own set of exceptions to map, you can us
142
142
143
143
""""
144
144
145
-
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to DI container. You could call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of :doc:`../features/dependencyinjection` feature.
145
+
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to the DI container. You can call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of the:doc:`../features/dependencyinjection` feature.
146
146
.. [#f2] If something doesn't work or you get stuck, please review current `QoS issues <https://github.com/search?q=repo%3AThreeMammals%2FOcelot+QoS&type=issues>`_ filtering by |QoS_label| label.
147
147
.. [#f3] We upgraded `Polly`_ version from v7.x to v8.x! The :ref:`qos-extensibility` feature was requested in issue `1875`_ and delivered by PR `1914`_ as a part of version `23.2`_.
Copy file name to clipboardExpand all lines: docs/features/requestaggregation.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -227,4 +227,4 @@ Gotchas
227
227
""""
228
228
229
229
.. [#f1] This feature was requested as part of `issue 79 <https://github.com/ThreeMammals/Ocelot/issues/79>`_ and further improvements were made as part of `issue 298 <https://github.com/ThreeMammals/Ocelot/issues/298>`_. A significant refactoring and revision of the `Multiplexer <https://github.com/ThreeMammals/Ocelot/tree/develop/src/Ocelot/Multiplexer>`_ design was carried out on March 4, 2024 in version `23.1 <https://github.com/ThreeMammals/Ocelot/releases/tag/23.1.0>`_, see PRs `1826 <https://github.com/ThreeMammals/Ocelot/pull/1826>`_ and `1462 <https://github.com/ThreeMammals/Ocelot/pull/1462>`_.
230
-
.. [#f2] :ref:`di-the-addocelot-method` adds default ASP.NET services to DI container. You could call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of :doc:`../features/dependencyinjection` feature.
230
+
.. [#f2] :ref:`di-the-addocelot-method` adds default ASP.NET services to the DI container. You can call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of the:doc:`../features/dependencyinjection` feature.
Copy file name to clipboardExpand all lines: docs/features/servicediscovery.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -541,7 +541,7 @@ But you can leave this ``Type`` option for compatibility between both designs.
541
541
542
542
""""
543
543
544
-
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to DI container. You could call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of :doc:`../features/dependencyinjection` feature.
544
+
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to the DI container. You can call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of the:doc:`../features/dependencyinjection` feature.
545
545
.. [#f2] :ref:`sd-consul-configuration-key` feature was requested in issue `346`_ as a part of version `7.0.0`_.
546
546
.. [#f3] Customization of :ref:`sd-consul-service-builder` was implemented as a part of bug `954`_ fixing and the feature was delivered in version `23.3`_.
Copy file name to clipboardExpand all lines: docs/features/tracing.rst
+1-1
Original file line number
Diff line number
Diff line change
@@ -88,4 +88,4 @@ Ocelot will now send tracing information to Butterfly when this Route is called.
88
88
89
89
""""
90
90
91
-
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to DI container. You could call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of :doc:`../features/dependencyinjection` feature.
91
+
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to the DI container. You can call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of the:doc:`../features/dependencyinjection` feature.
Ocelot is designed to work with ASP.NET and is currently on ``net6.0``, ``net7.0`` and ``net8.0`` frameworks.
4
+
Ocelot is designed to work with `ASP.NET Core <https://learn.microsoft.com/en-us/aspnet/core/?view=aspnetcore-9.0>`_ and is currently on `.NET 8 <https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle>`_ `LTS <https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#release-types>`_
5
+
and `.NET 9 <https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#lifecycle>`_ `STS <https://dotnet.microsoft.com/en-us/platform/support/policy/dotnet-core#release-types>`_ frameworks.
5
6
6
-
.NET 8.0
7
-
--------
8
-
9
-
Install NuGet package
10
-
^^^^^^^^^^^^^^^^^^^^^
7
+
Install
8
+
-------
11
9
12
10
Install Ocelot and it's dependencies using `NuGet <https://www.nuget.org/>`_.
13
-
You will need to create a `ASP.NET Core minimal API project <https://learn.microsoft.com/en-us/aspnet/core/tutorials/min-web-api>`_ and bring the package into it.
11
+
You will need to create a `ASP.NET Core minimal API project <https://learn.microsoft.com/en-us/aspnet/core/tutorials/min-web-api>`_ with "ASP.NET Core Empty" template but without ``app.Map*`` methods, and bring the package into it.
14
12
Then follow the startup below and :doc:`../features/configuration` sections to get up and running.
15
13
16
14
.. code-block:: powershell
@@ -20,108 +18,103 @@ Then follow the startup below and :doc:`../features/configuration` sections to g
20
18
All versions can be found in the `NuGet Gallery | Ocelot <https://www.nuget.org/packages/Ocelot/>`_.
21
19
22
20
Configuration
23
-
^^^^^^^^^^^^^
21
+
-------------
24
22
25
-
The following is a very basic **ocelot.json**. It won't do anything but should get Ocelot starting.
23
+
The following is a very basic `ocelot.json`_.
24
+
It won't do anything but should get Ocelot starting.
26
25
27
26
.. code-block:: json
28
27
29
28
{
30
-
"Routes": [],
31
-
"GlobalConfiguration": {
32
-
"BaseUrl": "https://api.mybusiness.com"
33
-
}
29
+
"Routes": [],
30
+
"DynamicRoutes": [],
31
+
"Aggregates": [],
32
+
"GlobalConfiguration": {
33
+
"BaseUrl": "https://api.mybusiness.com"
34
+
}
34
35
}
35
36
36
37
If you want some example that actually does something use the following:
The most important thing to note here is **BaseUrl** property.
61
-
Ocelot needs to know the URL it is running under in order to do Header find & replace and for certain administration configurations.
58
+
The most important thing to note here is ``BaseUrl`` property.
59
+
Ocelot needs to know the URL it is running under in order to do Header :ref:`ht-find-and-replace` and for certain :doc:`../features/administration` configurations.
62
60
When setting this URL it should be the external URL that clients will see Ocelot running on e.g.
63
-
If you are running containers Ocelot might run on the URL ``http://123.12.1.1:6543`` but has something like **nginx** in front of it responding on ``https://api.mybusiness.com``.
64
-
In this case the Ocelot **BaseUrl** should be ``https://api.mybusiness.com``.
61
+
If you are running containers Ocelot might run on the URL ``http://123.12.1.2:6543`` but has something like `nginx<https://nginx.org/>`_ in front of it responding on ``https://api.mybusiness.com``.
62
+
In this case the Ocelot ``BaseUrl`` should be ``https://api.mybusiness.com``.
65
63
66
-
If you are using containers and require Ocelot to respond to clients on ``http://123.12.1.1:6543`` then you can do this,
64
+
If you are using containers and require Ocelot to respond to clients on ``http://123.12.1.2:6543`` then you can do this,
67
65
however if you are deploying multiple Ocelot's you will probably want to pass this on the command line in some kind of script.
68
66
Hopefully whatever scheduler you are using can pass the IP.
69
67
70
68
Program
71
-
^^^^^^^
72
-
73
-
Then in your **Program.cs** you will want to have the following.
74
-
75
-
The main things to note are
69
+
-------
76
70
77
-
* ``AddOcelot()`` adds Ocelot required and default services [#f1]_
78
-
* ``UseOcelot().Wait()`` sets up all the Ocelot middlewares.
71
+
Then in your `Program.cs <https://github.com/ThreeMammals/Ocelot/blob/main/samples/Basic/Program.cs>`_ (with `top-level statements <https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements>`_) you will want to have the following.
79
72
80
73
.. code-block:: csharp
81
74
82
-
usingSystem.IO;
83
-
usingMicrosoft.AspNetCore.Hosting;
84
-
usingMicrosoft.Extensions.Configuration;
85
-
usingMicrosoft.Extensions.Hosting;
86
75
usingOcelot.DependencyInjection;
87
76
usingOcelot.Middleware;
88
77
89
-
namespaceOcelotBasic
78
+
varbuilder=WebApplication.CreateBuilder(args);
79
+
80
+
// Ocelot Basic setup
81
+
builder.Configuration
82
+
.SetBasePath(builder.Environment.ContentRootPath)
83
+
.AddOcelot(); // single ocelot.json file in read-only mode
* ``builder.Configuration.AddOcelot()`` adds single `ocelot.json`_ configuration file in read-only mode.
101
+
* ``builder.Services.AddOcelot(builder.Configuration)`` adds Ocelot required and default services [#f1]_
102
+
* ``app.UseOcelot()`` sets up all the Ocelot middlewares. Note, we have to await the threading result before calling ``app.Run()``
103
+
* Do not add endpoint mappings (minimal API methods) such as ``app.MapGet()`` because the Ocelot pipeline is not compatible with them!
104
+
105
+
Samples
106
+
-------
107
+
108
+
For beginners, we have prepared basic `samples <https://github.com/ThreeMammals/Ocelot/tree/main/samples>`_ to help Ocelot newbies clone, compile, and get it running.
109
+
110
+
* `Basic <https://github.com/ThreeMammals/Ocelot/tree/main/samples/Basic>`_ sample: It has a single configuration file, `ocelot.json`_.
111
+
* `Basic Configuration <https://github.com/ThreeMammals/Ocelot/tree/main/samples/Configuration>`_ sample: It has multiple configuration files (``ocelot.*.json``) to be merged into ``ocelot.json`` and written back to disk.
112
+
113
+
After running in Visual Studio [#f2]_, you may use ``API.http`` files to send testing requests to the ``localhost`` Ocelot application instance.
114
+
125
115
""""
126
116
127
-
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to DI container. You could call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of :doc:`../features/dependencyinjection` feature.
117
+
.. [#f1] :ref:`di-the-addocelot-method` adds default ASP.NET services to the DI container. You can call another extended :ref:`di-addocelotusingbuilder-method` while configuring services to develop your own :ref:`di-custom-builder`. See more instructions in the ":ref:`di-addocelotusingbuilder-method`" section of the :doc:`../features/dependencyinjection` feature.
118
+
.. [#f2] All sample projects are organized as the `Ocelot.Samples.sln <https://github.com/ThreeMammals/Ocelot/blob/main/samples/Ocelot.Samples.sln>`_ file for Visual Studio 2022 IDE.
0 commit comments