-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKrakendResource.cs
27 lines (22 loc) · 921 Bytes
/
KrakendResource.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
using Aspire.Hosting.ApplicationModel;
namespace NapalmCodes.Aspire.Hosting.Krakend;
/// <summary>
/// A resource that represents a KrakenD resource independent of the hosting model.
/// </summary>
/// <param name="name">Resource name.</param>
public class KrakendResource(string name) :
ContainerResource(name),
IResourceWithConnectionString
{
internal const string PrimaryEndpointName = "http";
private EndpointReference? _primaryEndpoint;
/// <summary>
/// Gets the primary endpoint for the KrakenD server.
/// </summary>
public EndpointReference PrimaryEndpoint => _primaryEndpoint ??= new(this, PrimaryEndpointName);
/// <summary>
/// Gets the connection string expression for the KrakenD server.
/// </summary>
public ReferenceExpression ConnectionStringExpression =>
ReferenceExpression.Create($"{PrimaryEndpoint.Property(EndpointProperty.Url)}");
}