refactor(controller): wrapper refactor for dynamic ports
This commit is contained in:
@@ -1,4 +1,12 @@
|
|||||||
lstWrapper/publish
|
lstWrapper/publish/wwwroot
|
||||||
|
lstWrapper/publish/appsettings-example.json
|
||||||
|
lstWrapper/publish/LstWrapper.deps.json
|
||||||
|
lstWrapper/publish/LstWrapper.dll
|
||||||
|
lstWrapper/publish/LstWrapper.exe
|
||||||
|
lstWrapper/publish/LstWrapper.pdb
|
||||||
|
lstWrapper/publish/LstWrapper.runtimeconfig.json
|
||||||
|
lstWrapper/publish/LstWrapper.staticwebassets.endpoints.json
|
||||||
|
web.config
|
||||||
controller/lst_ctl.exe
|
controller/lst_ctl.exe
|
||||||
controller/.env-example
|
controller/.env-example
|
||||||
scripts/update-controller-bumpBuild.ps1
|
scripts/update-controller-bumpBuild.ps1
|
||||||
|
|||||||
@@ -9,12 +9,15 @@ using Microsoft.AspNetCore.Builder;
|
|||||||
using Microsoft.AspNetCore.HttpOverrides;
|
using Microsoft.AspNetCore.HttpOverrides;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
// Register HttpClient so we can proxy HTTP traffic
|
// Register HttpClient so we can proxy HTTP traffic
|
||||||
builder.Services.AddHttpClient();
|
builder.Services.AddHttpClient();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
var port8080 = builder.Configuration.GetValue<int>("ProxyConfig:Port8080", 8080);
|
||||||
|
var port4000 = builder.Configuration.GetValue<int>("ProxyConfig:Port4000", 4000);
|
||||||
|
|
||||||
// Enable WebSocket support
|
// Enable WebSocket support
|
||||||
app.UseWebSockets();
|
app.UseWebSockets();
|
||||||
@@ -74,14 +77,14 @@ app.Run(async (HttpContext context) =>
|
|||||||
if (rawPath.StartsWith("/socket.io", StringComparison.OrdinalIgnoreCase) ||
|
if (rawPath.StartsWith("/socket.io", StringComparison.OrdinalIgnoreCase) ||
|
||||||
rawPath.StartsWith("/lst/socket.io", StringComparison.OrdinalIgnoreCase))
|
rawPath.StartsWith("/lst/socket.io", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
backendHttpBase = "http://localhost:8080";
|
backendHttpBase = $"http://localhost:{port8080}";
|
||||||
backendWsBase = "ws://localhost:8080";
|
backendWsBase = $"ws://localhost:{port8080}";
|
||||||
}
|
}
|
||||||
else if (rawPath.StartsWith("/lst/api/controller", StringComparison.OrdinalIgnoreCase) ||
|
else if (rawPath.StartsWith("/lst/api/controller", StringComparison.OrdinalIgnoreCase) ||
|
||||||
rawPath.StartsWith("/api/controller", StringComparison.OrdinalIgnoreCase))
|
rawPath.StartsWith("/api/controller", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
backendHttpBase = "http://localhost:8080";
|
backendHttpBase = $"http://localhost:{port8080}";
|
||||||
backendWsBase = "ws://localhost:8080";
|
backendWsBase = $"ws://localhost:{port8080}";
|
||||||
|
|
||||||
// Now strip only once
|
// Now strip only once
|
||||||
// var newPath = rawPath.Substring("/lst".Length);
|
// var newPath = rawPath.Substring("/lst".Length);
|
||||||
@@ -89,8 +92,8 @@ app.Run(async (HttpContext context) =>
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
backendHttpBase = "http://localhost:4000";
|
backendHttpBase = $"http://localhost:{port4000}";
|
||||||
backendWsBase = "ws://localhost:4000";
|
backendWsBase = $"ws://localhost:{port4000}";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle WebSocket requests
|
// Handle WebSocket requests
|
||||||
|
|||||||
13
lstWrapper/appsettings-example.json
Normal file
13
lstWrapper/appsettings-example.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"Logging": {
|
||||||
|
"LogLevel": {
|
||||||
|
"Default": "Information",
|
||||||
|
"Microsoft.AspNetCore": "Warning"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"AllowedHosts": "*",
|
||||||
|
"ProxyConfig": {
|
||||||
|
"Port8080": 8080,
|
||||||
|
"Port4000": 4000
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,5 +5,9 @@
|
|||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*"
|
"AllowedHosts": "*",
|
||||||
|
"ProxyConfig": {
|
||||||
|
"Port8080": 8080,
|
||||||
|
"Port4000": 4000
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user