Skip to content

Commit

Permalink
bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
hoseinzadehashraf committed Nov 21, 2023
1 parent 9459c64 commit c052c06
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
12 changes: 2 additions & 10 deletions Domain/Logic/Deserialize/StructureDeserializer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ static void LoadServices()
Name = x,
Icon = Config.Get("Microservice:" + x + ":Icon"),
UseIframe = Config.Get("Microservice:" + x + ":Iframe").ToLower() == "true",
BaseUrl = GetServiceBaseUrl(Config.Get("Microservice:" + x + ":Url"), Config.Get<bool>("Microservice:" + x + ":HasApiBackend")),
BaseUrl = Config.Get("Microservice:" + x + ":Url"),
HasApiBackend = Config.Get<bool>("Microservice:" + x + ":HasApiBackend", false),
InjectSingleSignon = Config.Get("Microservice:" + x + ":Sso").ToLower() == "true",
});
Expand All @@ -66,22 +66,14 @@ static async Task SetServicesFromXml()
{
Name = x.GetCleanName(),
UseIframe = x.GetValue<bool?>("@iframe") ?? false,
BaseUrl = GetServiceBaseUrl(url.StartsWith("http") ? url : $"https://{url}.{envDomain}", x.GetValue<bool?>("@hasapibackend") ?? false).ToLower(),
BaseUrl = (url.StartsWith("http") ? url : $"https://{url}.{envDomain}").ToLower(),
Icon = x.GetValue<string>("@icon"),
InjectSingleSignon = x.GetValue<bool?>("@sso") ?? false,
HasApiBackend = x.GetValue<bool?>("@hasapibackend") ?? false

}).ToList();
}

static string GetServiceBaseUrl(string baseUrl, bool hasApiBackend)
{
if (!hasApiBackend) return baseUrl;
var domain = Config.Get("Authentication:Cookie:Domain").Trim('/');
baseUrl = baseUrl.Replace("." + domain, "api." + domain);
return baseUrl;
}

static void Run(string actionName, Func<bool> condition, Action action)
{
if (condition() == false) return;
Expand Down
13 changes: 11 additions & 2 deletions Domain/Logic/Service.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Olive.Entities;
using Olive.Entities.Data;
using Olive.Microservices.Hub.Utilities.UrlExtensions;
using Polly.Caching;

namespace Olive.Microservices.Hub
{
Expand Down Expand Up @@ -52,7 +53,7 @@ public override async Task Validate()
public string GetHubImplementationUrl(string relativeUrl)
=> GetHubImplementationUrlPrefix().AppendUrlPath(relativeUrl);

public string GetAbsoluteImplementationUrl(string relativeUrl) => BaseUrl.AppendUrlPath(relativeUrl);
public string GetAbsoluteImplementationUrl(string relativeUrl, bool withApi = false) => (withApi ? GetServiceBaseUrlWithApi(BaseUrl, HasApiBackend) : BaseUrl).AppendUrlPath(relativeUrl);
public static Service GetServiceFromURL(string relativeUrl)
{
Service hub = null;
Expand Down Expand Up @@ -87,9 +88,17 @@ public override Task<IEntity> Get(object objectID)
}
}

string GetServiceBaseUrlWithApi(string baseUrl, bool hasApiBackend)
{
if (!hasApiBackend) return baseUrl;
var domain = Config.Get("Authentication:Cookie:Domain").Trim('/');
baseUrl = baseUrl.Replace("." + domain, "api." + domain);
return baseUrl;
}

public async Task GetAndSaveFeaturesJson()
{
var url = GetAbsoluteImplementationUrl("olive/features").AsUri();
var url = GetAbsoluteImplementationUrl("olive/features", true).AsUri();

try
{
Expand Down
2 changes: 1 addition & 1 deletion Olive.Microservices.Hub.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<Authors>Geeks Ltd</Authors>
<RepositoryUrl>https://github.com/Geeksltd/Olive.Microservices.Hub/tree/master/Olive.Microservices.Hub</RepositoryUrl>
<PackageIcon>icon.png</PackageIcon>
<Version>1.5.32</Version>
<Version>1.5.33</Version>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<GenerateTargetFrameworkAttribute>false</GenerateTargetFrameworkAttribute>
<Nullable>warnings</Nullable>
Expand Down

0 comments on commit c052c06

Please sign in to comment.