2021-12-10 23:11:26 +01:00
|
|
|
using zero.Applications;
|
|
|
|
|
|
|
|
|
|
namespace zero.Demo;
|
|
|
|
|
|
|
|
|
|
public class DevApplicationResolverHandler : IApplicationResolverHandler
|
|
|
|
|
{
|
|
|
|
|
IWebHostEnvironment Env;
|
|
|
|
|
|
|
|
|
|
static Dictionary<int, string> PortMap = new()
|
|
|
|
|
{
|
|
|
|
|
{ 2310, "app.hofbauer" },
|
2021-12-11 15:24:47 +01:00
|
|
|
{ 2100, "app.hofbauer" },
|
2021-12-10 23:11:26 +01:00
|
|
|
{ 2300, "app.brothers" },
|
|
|
|
|
{ 2320, "app.sporthuber" }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
public DevApplicationResolverHandler(IWebHostEnvironment env)
|
|
|
|
|
{
|
|
|
|
|
Env = env;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-12-13 13:40:04 +01:00
|
|
|
public bool TryResolve(HttpContext context, IEnumerable<Application> applications, out Application resolved)
|
2021-12-10 23:11:26 +01:00
|
|
|
{
|
2021-12-13 13:40:04 +01:00
|
|
|
resolved = null;
|
|
|
|
|
|
2021-12-10 23:11:26 +01:00
|
|
|
//if (!Env.IsDevelopment())
|
|
|
|
|
//{
|
2021-12-13 13:40:04 +01:00
|
|
|
// return false;
|
2021-12-10 23:11:26 +01:00
|
|
|
//}
|
2021-12-13 13:40:04 +01:00
|
|
|
|
|
|
|
|
if (context.Request.Host.Host.Contains("ngrok.io"))
|
2021-12-10 23:11:26 +01:00
|
|
|
{
|
2021-12-13 13:40:04 +01:00
|
|
|
resolved = applications.First(x => x.Id == "app.hofbauer");
|
|
|
|
|
return true;
|
2021-12-10 23:11:26 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-13 13:40:04 +01:00
|
|
|
if (context.Request.Host.Port.HasValue && PortMap.TryGetValue(context.Request.Host.Port.Value, out string appId))
|
2021-12-10 23:11:26 +01:00
|
|
|
{
|
2021-12-13 13:40:04 +01:00
|
|
|
resolved = applications.FirstOrDefault(x => x.Id == appId);
|
|
|
|
|
return true;
|
2021-12-10 23:11:26 +01:00
|
|
|
}
|
|
|
|
|
|
2021-12-13 13:40:04 +01:00
|
|
|
return false;
|
2021-12-10 23:11:26 +01:00
|
|
|
}
|
|
|
|
|
}
|