Merge remote-tracking branch 'refs/remotes/origin/v14/dev' into v15/merge

# Conflicts:
#	Directory.Packages.props
#	tests/Directory.Packages.props
#	version.json
This commit is contained in:
nikolajlauridsen
2024-07-19 11:28:38 +02:00
110 changed files with 3375 additions and 897 deletions

View File

@@ -47,4 +47,37 @@ public interface IPublishedRouter
/// </para>
/// </remarks>
Task<IPublishedRequest> UpdateRequestAsync(IPublishedRequest request, IPublishedContent? publishedContent);
/// <summary>
/// Finds the site root (if any) matching the http request, and updates the PublishedRequest and VariationContext accordingly.
/// <remarks>
/// <para>
/// This method is used for VirtualPage routing.
/// </para>
/// <para>
/// In this case we do not want to run the entire routing pipeline since ContentFinders are not needed here.
/// However, we do want to set the culture on VariationContext and PublishedRequest to the values specified by the domains.
/// </para>
/// </remarks>
/// </summary>
/// <param name="request">The request to update the culture on domain on</param>
/// <returns>True if a domain was found otherwise false.</returns>
bool RouteDomain(IPublishedRequestBuilder request) => false;
/// <summary>
/// Finds the site root (if any) matching the http request, and updates the VariationContext accordingly.
/// </summary>
/// <remarks>
/// <para>
/// This is used for VirtualPage routing.
/// </para>
/// <para>
/// This is required to set the culture on VariationContext to the values specified by the domains, before the FindContent method is called.
/// In order to allow the FindContent implementer to correctly find content based off the culture. Before the PublishedRequest is built.
/// </para>
/// </remarks>
/// <param name="uri">The URI to resolve the domain from.</param>
/// <returns>True if a domain was found, otherwise false.</returns>
bool UpdateVariationContext(Uri uri) => false;
}

View File

@@ -108,7 +108,7 @@ public class PublishedRouter : IPublishedRouter
// find domain
if (builder.Domain == null)
{
FindDomain(builder);
FindAndSetDomain(builder);
}
await RouteRequestInternalAsync(builder);
@@ -185,7 +185,7 @@ public class PublishedRouter : IPublishedRouter
private async Task<IPublishedRequest> TryRouteRequest(IPublishedRequestBuilder request)
{
FindDomain(request);
FindAndSetDomain(request);
if (request.IsRedirect())
{
@@ -270,18 +270,31 @@ public class PublishedRouter : IPublishedRouter
// to find out the appropriate template
}
/// <summary>
/// Finds the site root (if any) matching the http request, and updates the PublishedRequest accordingly.
/// </summary>
/// <returns>A value indicating whether a domain was found.</returns>
internal bool FindDomain(IPublishedRequestBuilder request)
/// <inheritdoc />
public bool RouteDomain(IPublishedRequestBuilder request)
{
var found = FindAndSetDomain(request);
HandleWildcardDomains(request);
SetVariationContext(request.Culture);
return found;
}
/// <inheritdoc />
public bool UpdateVariationContext(Uri uri)
{
DomainAndUri? domain = FindDomain(uri, out _);
SetVariationContext(domain?.Culture);
return domain?.Culture is not null;
}
private DomainAndUri? FindDomain(Uri uri, out string? defaultCulture)
{
const string tracePrefix = "FindDomain: ";
// note - we are not handling schemes nor ports here.
if (_logger.IsEnabled(LogLevel.Debug))
{
_logger.LogDebug("{TracePrefix}Uri={RequestUri}", tracePrefix, request.Uri);
_logger.LogDebug("{TracePrefix}Uri={RequestUri}", tracePrefix, uri);
}
IUmbracoContext umbracoContext = _umbracoContextAccessor.GetRequiredUmbracoContext();
@@ -315,10 +328,20 @@ public class PublishedRouter : IPublishedRouter
domains = domains?.Where(IsPublishedContentDomain).ToList();
var defaultCulture = domainsCache?.DefaultCulture;
defaultCulture = domainsCache?.DefaultCulture;
return DomainUtilities.SelectDomain(domains, uri, defaultCulture: defaultCulture);
}
/// <summary>
/// Finds the site root (if any) matching the http request, and updates the PublishedRequest accordingly.
/// </summary>
/// <returns>A value indicating whether a domain was found.</returns>
internal bool FindAndSetDomain(IPublishedRequestBuilder request)
{
const string tracePrefix = "FindDomain: ";
// try to find a domain matching the current request
DomainAndUri? domainAndUri = DomainUtilities.SelectDomain(domains, request.Uri, defaultCulture: defaultCulture);
DomainAndUri? domainAndUri = FindDomain(request.Uri, out var defaultCulture);
// handle domain - always has a contentId and a culture
if (domainAndUri != null)