Class LeaderRouter
Allows to route incoming HTTP request to the cluster leader.
Inherited Members
Namespace: DotNext.Net.Cluster.Consensus.Raft.Http
Assembly: DotNext.AspNetCore.Cluster.dll
Syntax
[CLSCompliant(false)]
public static class LeaderRouter
Methods
| Improve this Doc View SourceRedirectToLeader(IApplicationBuilder, PathString, Nullable<Int32>, Func<HttpResponse, Uri, Task>)
Defines that the relative path should be handled by a leader node only.
Declaration
public static IApplicationBuilder RedirectToLeader(this IApplicationBuilder builder, PathString path, int? applicationPortHint = default(int? ), Func<HttpResponse, Uri, Task> redirection = null)
Parameters
Type | Name | Description |
---|---|---|
IApplicationBuilder | builder | The request processing pipeline builder. |
PathString | path | The path that a leader must handle. |
Nullable<Int32> | applicationPortHint | The port number to be inserted into Location header instead of automatically detected port of the local TCP listener. |
Func<HttpResponse, Uri, Task> | redirection | The redirection logic. |
Returns
Type | Description |
---|---|
IApplicationBuilder | The request pipeline builder. |
Remarks
If the current node is not the leader then request will be
redirected automatically to the leader node with 302 (Moved Permanently).
If there are no consensus then the request will be failed with 503 (Service Unavailable).
You can override redirection behavior using custom redirection
.
applicationPortHint
used to highligh real port of the application endpoints in the cluster.
This parameter can be used if your deployment is based on Docker. If it is not specified then router trying to add
local port of the TCP listener. This may be invalid due to port mappings in Docker.