-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathRemoteAppClientOptions.cs
61 lines (51 loc) · 1.75 KB
/
RemoteAppClientOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.ComponentModel.DataAnnotations;
using System.Net.Http;
namespace Microsoft.AspNetCore.SystemWebAdapters;
/// <summary>
/// Options for connecting to a remote app.
/// </summary>
public class RemoteAppClientOptions
{
private Uri _remoteAppUrl = null!;
/// <summary>
/// Gets or sets the header used to store the API key
/// </summary>
[Required]
public string ApiKeyHeader { get; set; } = RemoteConstants.ApiKeyHeaderName;
/// <summary>
/// Gets or sets an API key used to secure the endpoint
/// </summary>
[Required, ApiKey]
public string ApiKey { get; set; } = null!;
/// <summary>
/// Gets or sets the remote app url
/// </summary>
[Required]
public Uri RemoteAppUrl
{
get => _remoteAppUrl;
set
{
ArgumentNullException.ThrowIfNull(value);
// Path must end in '/' so that it will combine correctly with subpaths
if (!value.AbsolutePath.EndsWith('/'))
{
var builder = new UriBuilder(value);
builder.Path += "/";
value = builder.Uri;
}
_remoteAppUrl = value;
}
}
/// <summary>
/// Gets or sets an <see cref="HttpMessageHandler"/> to use for making requests to the remote app. Used if BackchannelClient is null.
/// </summary>
public HttpMessageHandler? BackchannelHandler { get; set; }
/// <summary>
/// Gets or sets an <see cref="HttpClient"/> to use for making requests to the remote app.
/// </summary>
public HttpClient? BackchannelClient { get; set; }
}