* Add tenant awareness to bookmark handling and route resolution Added tenant ID support across various components, including bookmark updates, route resolution, and middleware processing. This ensures that bookmark and route operations can now appropriately handle tenant-specific data, improving the system's multitenancy capabilities. * Add Multitenant HTTP Routing feature to Tenants module Introduced a new MultitenantHttpRoutingFeature class to the Elsa.Tenants.AspNetCore module, enhancing the tenant resolution capabilities. Moved RoutePrefixTenantResolver from Elsa.Http to Elsa.Tenants.AspNetCore and updated relevant project references and namespaces accordingly. This refactor improves modularity and separation of concerns between HTTP and tenancy features. * Refactor route handling and tenant configuration Removed redundant `RouteTableExtensions` and replaced with new route providers and updaters, enhancing flexibility and modularity. Introduced tenant-specific HTTP endpoint configurations for better customization and configuration management. * Rename HttpEndpointBookmarkStimulus to HttpEndpointBookmarkPayload Refactor various classes and methods to reflect the renaming from `HttpEndpointBookmarkStimulus` to `HttpEndpointBookmarkPayload`. Add and configure new extension methods for tenant route handling, update the route provider to support multi-tenancy, and adjust the tenants provider to bind configuration properly. * Add HeaderTenantResolver and refactor Http namespace. Introduce HeaderTenantResolver to resolve tenants via HTTP headers. Refactor multiple classes and interfaces to move from the Elsa.Http.Models namespace directly into Elsa.Http for clarity and consistency. * Add Host-based tenant resolution Implemented a HostTenantResolver to resolve tenants based on the request's host and updated tenant configurations with host information. Modified the tenant resolver pipeline and added the new host resolver to the service registrations. * Add tenant-aware caching and accessor support Enhanced caching by incorporating tenant identifiers into cache keys for more granular cache management. Introduced ITenantAccessor dependencies in various services to retrieve the current tenant information. This ensures that cache entries are correctly isolated per tenant. * Reorder tenant resolvers for pipeline setup. Reordered the tenant resolvers in the pipeline to prioritize HostTenantResolver before RoutePrefixTenantResolver. This ensures that tenant resolution is correctly aligned with host-based resolving before checking the route prefix. * Remove unused imports This commit eliminates redundant `using` directives across multiple files to streamline the codebase. This cleanup helps improve code readability and maintainability by removing unnecessary dependencies.
33 lines
1.3 KiB
C#
33 lines
1.3 KiB
C#
using Elsa.Http.Options;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace Elsa.Http.Services;
|
|
|
|
/// <inheritdoc />
|
|
public class DefaultAbsoluteUrlProvider : IAbsoluteUrlProvider
|
|
{
|
|
private readonly IOptions<HttpActivityOptions> _options;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="DefaultAbsoluteUrlProvider"/> class.
|
|
/// </summary>
|
|
public DefaultAbsoluteUrlProvider(IOptions<HttpActivityOptions> options) => _options = options;
|
|
|
|
/// <inheritdoc />
|
|
public Uri ToAbsoluteUrl(string relativePath)
|
|
{
|
|
var baseUrl = _options.Value.BaseUrl;
|
|
|
|
if (baseUrl == null)
|
|
throw new Exception(
|
|
"There was no base URL configured, which means no absolute URL can be generated from outside the context of an HTTP request. Please make sure that `HttpActivityOptions` is configured correctly. The configuration key used in most Elsa samples is usually: \"Elsa:Server:BaseUrl\"");
|
|
|
|
// To not lose any base path information, we need to ensure that:
|
|
// - Base path ends with a slash.
|
|
// - Relative path does NOT start with a slash.
|
|
var baseUri = new Uri(baseUrl.ToString().TrimEnd('/') + '/');
|
|
relativePath = relativePath.TrimStart('/');
|
|
|
|
return new Uri(baseUri, relativePath);
|
|
}
|
|
} |