mirror of
https://github.com/oqtane/oqtane.framework.git
synced 2025-05-17 18:14:22 +00:00
44 lines
1.2 KiB
C#
44 lines
1.2 KiB
C#
using System;
|
|
using Oqtane.Models;
|
|
|
|
namespace Oqtane.Services
|
|
{
|
|
public class ServiceBase
|
|
{
|
|
|
|
public static string CreateApiUrl(Alias alias, string absoluteUri, string serviceName)
|
|
{
|
|
Uri uri = new Uri(absoluteUri);
|
|
|
|
string apiurl;
|
|
if (alias != null)
|
|
{
|
|
// build a url which passes the alias that may include a subfolder for multi-tenancy
|
|
apiurl = $"{uri.Scheme}://{alias.Name}/";
|
|
if (alias.Path == string.Empty)
|
|
{
|
|
apiurl += "~/";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// build a url which ignores any subfolder for multi-tenancy
|
|
apiurl = $"{uri.Scheme}://{uri.Authority}/~/";
|
|
}
|
|
apiurl += $"api/{serviceName}";
|
|
|
|
return apiurl;
|
|
}
|
|
|
|
public static string CreateCrossTenantUrl(string url, Alias alias)
|
|
{
|
|
if (alias != null)
|
|
{
|
|
url += (url.Contains("?")) ? "&" : "?";
|
|
url += "aliasid=" + alias.AliasId.ToString();
|
|
}
|
|
return url;
|
|
}
|
|
}
|
|
}
|