* Incremental work on Telnyx integration * Incremental port of Telnyx activities * Fix polymorphic JSON serialization for webhook data * Fix IsFirstPass logic * Fix trigger base to prevent activity auto completion * Temporarily disable persistent snapshotting provider for testing * Fix namespaces * Add method to register activities in bulk using marker type * Fix Telnyx refit client setup * Register all Telnyx activities by default * Incremental work on webhook driven resumption and correlation * Incremental work on post-bookmark signaling * Fix bookmark resolution * Include correlation ID with bookmark * Fix Telnyx resumption input * Replace bookmark persisted signal with handler * Fix SpeakText completion * Add flow outcomes to SpeakText activity * Update GatherUsingSpeak and GatherUsingaudio * Refactor "is first pass" concept * Fix WebhookEvent activity * Add HTTP absolute URL provider * Formatting and small changes * Various API enhancements
28 lines
1.1 KiB
C#
28 lines
1.1 KiB
C#
using Elsa.Http.Options;
|
|
using Elsa.Http.Services;
|
|
using Microsoft.Extensions.Options;
|
|
|
|
namespace Elsa.Http.Implementations;
|
|
|
|
public class DefaultAbsoluteUrlProvider : IAbsoluteUrlProvider
|
|
{
|
|
private readonly IOptions<HttpActivityOptions> _options;
|
|
public DefaultAbsoluteUrlProvider(IOptions<HttpActivityOptions> options) => _options = options;
|
|
|
|
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);
|
|
}
|
|
} |