diff --git a/src/Falu/FaluClientOptions.cs b/src/Falu/FaluClientOptions.cs
index 14d8369..88e3a44 100644
--- a/src/Falu/FaluClientOptions.cs
+++ b/src/Falu/FaluClientOptions.cs
@@ -19,6 +19,11 @@ public class FaluClientOptions
///
public int Retries { get; set; } = 2;
+ ///
+ /// Host to use when uploading files
+ ///
+ public string FilesHost { get; set; } = "files.falu.io";
+
///
/// Information about the application.
/// It is recommended for use only with third party services for identification purposes.
diff --git a/src/Falu/Files/FilesServiceClient.cs b/src/Falu/Files/FilesServiceClient.cs
index ff628cf..a7a9baa 100644
--- a/src/Falu/Files/FilesServiceClient.cs
+++ b/src/Falu/Files/FilesServiceClient.cs
@@ -79,7 +79,7 @@ public virtual Task> CreateAsync(FileCreateOptions option
content.Add(new StringContent(options.Expires!.Value.ToString("O")), "expires");
}
- var uri = MakePath();
+ var uri = new UriBuilder(BackChannel.BaseAddress!) { Host = Options.FilesHost, Path = MakePath() }.ToString();
return RequestResourceAsync(uri, HttpMethod.Post, content, requestOptions, cancellationToken);
}
}
diff --git a/tests/Falu.Tests/Clients/BaseServiceClientTests.cs b/tests/Falu.Tests/Clients/BaseServiceClientTests.cs
index 7337f96..8771fec 100644
--- a/tests/Falu.Tests/Clients/BaseServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/BaseServiceClientTests.cs
@@ -27,6 +27,7 @@ protected DynamicHttpMessageHandler GetAsync_Handler(RequestOptions? requestOpti
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Get, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data.Id!}", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -49,6 +50,7 @@ protected DynamicHttpMessageHandler ListAsync_Handler(bool? hasContinuationToken
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Get, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -74,11 +76,12 @@ protected DynamicHttpMessageHandler ListAsync_Handler(bool? hasContinuationToken
return handler;
}
- protected DynamicHttpMessageHandler CreateAsync_Handler(RequestOptions? requestOptions = null)
+ protected DynamicHttpMessageHandler CreateAsync_Handler(RequestOptions? requestOptions = null, string? host = ApiHost)
{
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(host, req.RequestUri!.Host);
Assert.Equal($"{BasePath}", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -102,6 +105,7 @@ protected DynamicHttpMessageHandler UpdateAsync_Handler(RequestOptions? requestO
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Patch, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data.Id!}", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -123,6 +127,7 @@ protected DynamicHttpMessageHandler DeleteAsync_Handler(RequestOptions? requestO
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Delete, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data.Id!}", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -138,6 +143,7 @@ public class BaseServiceClientTests
{
private const string TestKey = "test";
+ protected const string ApiHost = "api.falu.io";
protected const string WorkspaceId = "wksp_602a8dd0a54847479a874de4";
protected const string IdempotencyKey = "05bc69eb-218d-46f2-8812-5bede8592abf";
diff --git a/tests/Falu.Tests/Clients/FilesServiceClientTests.cs b/tests/Falu.Tests/Clients/FilesServiceClientTests.cs
index e8bf319..21726bc 100644
--- a/tests/Falu.Tests/Clients/FilesServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/FilesServiceClientTests.cs
@@ -92,7 +92,7 @@ await TestAsync(handler, async (client) =>
[ClassData(typeof(RequestOptionsData))]
public async Task CreateAsync_Works(RequestOptions requestOptions)
{
- var handler = CreateAsync_Handler(requestOptions);
+ var handler = CreateAsync_Handler(requestOptions, "files.falu.io");
await TestAsync(handler, async (client) =>
{
diff --git a/tests/Falu.Tests/Clients/IdentityVerificationsServiceClientTests.cs b/tests/Falu.Tests/Clients/IdentityVerificationsServiceClientTests.cs
index 823b0c8..57cade8 100644
--- a/tests/Falu.Tests/Clients/IdentityVerificationsServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/IdentityVerificationsServiceClientTests.cs
@@ -128,6 +128,7 @@ public async Task CancelAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/cancel", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -156,6 +157,7 @@ public async Task RedactAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/redact", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
diff --git a/tests/Falu.Tests/Clients/MessageBatchesServiceClientTests.cs b/tests/Falu.Tests/Clients/MessageBatchesServiceClientTests.cs
index 541a0be..f6a28e1 100644
--- a/tests/Falu.Tests/Clients/MessageBatchesServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/MessageBatchesServiceClientTests.cs
@@ -137,6 +137,7 @@ public async Task StatusAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Get, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/status", req.RequestUri!.AbsolutePath);
var response = new HttpResponseMessage(HttpStatusCode.OK)
@@ -163,6 +164,7 @@ public async Task CancelAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/cancel", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -191,6 +193,7 @@ public async Task RedactAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/redact", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
diff --git a/tests/Falu.Tests/Clients/MessageStreamsServiceClientTests.cs b/tests/Falu.Tests/Clients/MessageStreamsServiceClientTests.cs
index 53b2ea9..e138295 100644
--- a/tests/Falu.Tests/Clients/MessageStreamsServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/MessageStreamsServiceClientTests.cs
@@ -115,6 +115,7 @@ public async Task ArchiveAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/archive", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -145,6 +146,7 @@ public async Task UnarchiveAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id!}/unarchive", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
diff --git a/tests/Falu.Tests/Clients/MessageTemplatesServiceClientTests.cs b/tests/Falu.Tests/Clients/MessageTemplatesServiceClientTests.cs
index 592cc5e..c567ebf 100644
--- a/tests/Falu.Tests/Clients/MessageTemplatesServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/MessageTemplatesServiceClientTests.cs
@@ -150,6 +150,7 @@ public async Task ValidateAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/validate", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
diff --git a/tests/Falu.Tests/Clients/MessagesServiceClientTests.cs b/tests/Falu.Tests/Clients/MessagesServiceClientTests.cs
index a4035b0..1208035 100644
--- a/tests/Falu.Tests/Clients/MessagesServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/MessagesServiceClientTests.cs
@@ -161,6 +161,7 @@ public async Task CancelAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/cancel", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -189,6 +190,7 @@ public async Task RedactAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/redact", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
diff --git a/tests/Falu.Tests/Clients/MoneyBalancesServiceClientTests.cs b/tests/Falu.Tests/Clients/MoneyBalancesServiceClientTests.cs
index 3c4296e..5e4af6c 100644
--- a/tests/Falu.Tests/Clients/MoneyBalancesServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/MoneyBalancesServiceClientTests.cs
@@ -58,6 +58,7 @@ public async Task RefreshAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/refresh", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
diff --git a/tests/Falu.Tests/Clients/PaymentAuthorizationsServiceClientTests.cs b/tests/Falu.Tests/Clients/PaymentAuthorizationsServiceClientTests.cs
index 4397421..a96409d 100644
--- a/tests/Falu.Tests/Clients/PaymentAuthorizationsServiceClientTests.cs
+++ b/tests/Falu.Tests/Clients/PaymentAuthorizationsServiceClientTests.cs
@@ -103,6 +103,7 @@ public async Task ApproveAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/approve", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);
@@ -135,6 +136,7 @@ public async Task DeclineAsync_Works(RequestOptions requestOptions)
var handler = new DynamicHttpMessageHandler((req, ct) =>
{
Assert.Equal(HttpMethod.Post, req.Method);
+ Assert.Equal(ApiHost, req.RequestUri!.Host);
Assert.Equal($"{BasePath}/{Data!.Id}/decline", req.RequestUri!.AbsolutePath);
AssertRequestHeaders(req, requestOptions);