mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-23 07:12:51 +08:00

* hacked together load balancing reroutes in fileconfig * some renaming and refactoring * more renames * hacked away the old config json * test for issue 213 * renamed key * dont share ports * oops * updated docs * mvoed docs around * port being used
41 lines
1.7 KiB
ReStructuredText
41 lines
1.7 KiB
ReStructuredText
Middleware Injection and Overrides
|
|
==================================
|
|
|
|
Warning use with caution. If you are seeing any exceptions or strange behavior in your middleware
|
|
pipeline and you are using any of the following. Remove them and try again!
|
|
|
|
When setting up Ocelot in your Startup.cs you can provide some additonal middleware
|
|
and override middleware. This is done as follos.
|
|
|
|
.. code-block:: csharp
|
|
|
|
var configuration = new OcelotMiddlewareConfiguration
|
|
{
|
|
PreErrorResponderMiddleware = async (ctx, next) =>
|
|
{
|
|
await next.Invoke();
|
|
}
|
|
};
|
|
|
|
app.UseOcelot(configuration);
|
|
|
|
In the example above the provided function will run before the first piece of Ocelot middleware.
|
|
This allows a user to supply any behaviours they want before and after the Ocelot pipeline has run.
|
|
This means you can break everything so use at your own pleasure!
|
|
|
|
The user can set functions against the following.
|
|
|
|
* PreErrorResponderMiddleware - Already explained above.
|
|
|
|
* PreAuthenticationMiddleware - This allows the user to run pre authentication logic and then call Ocelot's authentication middleware.
|
|
|
|
* AuthenticationMiddleware - This overrides Ocelots authentication middleware.
|
|
|
|
* PreAuthorisationMiddleware - This allows the user to run pre authorisation logic and then call Ocelot's authorisation middleware.
|
|
|
|
* AuthorisationMiddleware - This overrides Ocelots authorisation middleware.
|
|
|
|
* PreQueryStringBuilderMiddleware - This alows the user to manipulate the query string on the http request before it is passed to Ocelots request creator.
|
|
|
|
Obviously you can just add middleware as normal before the call to app.UseOcelot() It cannot be added
|
|
after as Ocelot does not call the next middleware. |