-
-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce router for reverse proxy which seems more reasonable.
- Loading branch information
1 parent
63c80bb
commit 7ab39f5
Showing
3 changed files
with
55 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using GenHTTP.Api.Modules; | ||
using GenHTTP.Api.Protocol; | ||
using GenHTTP.Api.Routing; | ||
using GenHTTP.Modules.Core.General; | ||
|
||
namespace GenHTTP.Modules.Core.Proxy | ||
{ | ||
|
||
public class ReverseProxyRouter : RouterBase, IRouter | ||
{ | ||
|
||
#region Get-/Setters | ||
|
||
private ReverseProxyProvider Provider { get; } | ||
|
||
#endregion | ||
|
||
#region Initialization | ||
|
||
public ReverseProxyRouter(string upstream, TimeSpan connectTimeout, TimeSpan readTimeout, IContentProvider? errorHandler) : base(null, errorHandler) | ||
{ | ||
Provider = new ReverseProxyProvider(upstream, connectTimeout, readTimeout, null); | ||
} | ||
|
||
#endregion | ||
|
||
#region Functionality | ||
|
||
public override IEnumerable<ContentElement> GetContent(IRequest request, string basePath) => new List<ContentElement>(); | ||
|
||
public override void HandleContext(IEditableRoutingContext current) | ||
{ | ||
current.RegisterContent(Provider); | ||
current.Scope(this); | ||
} | ||
|
||
public override string? Route(string path, int currentDepth) => Parent.Route(path, currentDepth); | ||
|
||
#endregion | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters