Skip to content

Commit

Permalink
fix: configured subdomain netapp routing
Browse files Browse the repository at this point in the history
  • Loading branch information
radu-popescu committed Mar 21, 2024
1 parent 34111a1 commit 8f38cab
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
3 changes: 2 additions & 1 deletion docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ services:
- Middleware__Organization=5G-ERA-DEV
- Middleware__InstanceName=BB
- Middleware__InstanceType=Edge
- Middleware__Address=localhost:5047
- Middleware__Address=http://localhost:5047
ports:
- "5036:80"
- "7036:443"
Expand Down Expand Up @@ -81,6 +81,7 @@ services:
- Middleware__Organization=5G-ERA-DEV
- Middleware__InstanceName=BB
- Middleware__InstanceType=Edge
- Middleware__Address=http://localhost:5047
ports:
- "5047:80"
- "7047:443"
Expand Down
2 changes: 2 additions & 0 deletions src/OcelotGateway/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

var config = builder.Configuration.GetSection(JwtConfig.ConfigName).Get<JwtConfig>();
builder.Services.Configure<JwtConfig>(builder.Configuration.GetSection(JwtConfig.ConfigName));
//var mwConfig = builder.Configuration.GetSection(MiddlewareConfig.ConfigName).Get<MiddlewareConfig>();
builder.Services.Configure<MiddlewareConfig>(builder.Configuration.GetSection(MiddlewareConfig.ConfigName));

builder.Services.AddAuthentication(options =>
{
Expand Down
22 changes: 18 additions & 4 deletions src/OcelotGateway/Services/GatewayConfigurationService.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
using Middleware.Common.MessageContracts;
using System.Security.Policy;
using System.Text;
using MassTransit.Configuration;
using Microsoft.Extensions.Options;
using Middleware.Common.Config;
using Middleware.Common.MessageContracts;
using Middleware.Models.ExtensionMethods;
using Yarp.ReverseProxy.Configuration;
using Yarp.ReverseProxy.Transforms;
Expand All @@ -9,11 +14,13 @@ public class GatewayConfigurationService
{
private readonly InMemoryConfigProvider _inMemoryConfigProvider;
private readonly ILogger<GatewayConfigurationService> _logger;
private readonly IOptions<MiddlewareConfig> _mwConfig;

public GatewayConfigurationService(IProxyConfigProvider inMemoryConfigProvider,
ILogger<GatewayConfigurationService> logger)
ILogger<GatewayConfigurationService> logger, IOptions<MiddlewareConfig> mwConfig)
{
_logger = logger;
_mwConfig = mwConfig;
if (inMemoryConfigProvider is InMemoryConfigProvider imcp)
_inMemoryConfigProvider = imcp;
}
Expand Down Expand Up @@ -41,14 +48,21 @@ public void CreateDynamicRoute(GatewayAddNetAppEntryMessage msg)
address);
var path = msg.Route.SanitizeToUriPath();
_logger.LogInformation("Opening new route with path: {path}", path);
string mwAddress = _mwConfig.Value.Address;
int position = 7;
StringBuilder stringBuilder = new StringBuilder(mwAddress);
stringBuilder.Insert(position, path+".");
string newHost = stringBuilder.ToString();
var routeCfg = new RouteConfig
{
RouteId = msg.NetAppName + "-Route",
Match = new()
{
Path = "/" + path + "/{**remainder}"
//ros-object-detection.middleware.net
//Path = "/" + path + "/{**remainder}",
Hosts = new[] {newHost}
},
ClusterId = clusterCfg.ClusterId //
ClusterId = clusterCfg.ClusterId
};
var routeSocketIoCfg = new RouteConfig
{
Expand Down

0 comments on commit 8f38cab

Please sign in to comment.