Add version endpoint
This commit is contained in:
@@ -12,6 +12,9 @@
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Cronos" Version="0.8.4" />
|
||||
<PackageReference Include="FastEndpoints" Version="5.24.0" />
|
||||
<PackageReference Include="GitVersion.MsBuild" Version="5.12.0">
|
||||
<PrivateAssets>all</PrivateAssets>
|
||||
</PackageReference>
|
||||
<PackageReference Include="LazyCache.AspNetCore" Version="2.4.0" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.4" />
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="8.0.4">
|
||||
|
||||
40
Features/Version/Get/GetVersionEndpoint.cs
Normal file
40
Features/Version/Get/GetVersionEndpoint.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
|
||||
using System.Text;
|
||||
|
||||
namespace ConnectionsAPI.Features.Version.Get
|
||||
{
|
||||
public class GetVersionEndpoint : EndpointWithoutRequest<string>
|
||||
{
|
||||
private static readonly int START_YEAR = 2024;
|
||||
|
||||
public override void Configure()
|
||||
{
|
||||
Get("/version");
|
||||
AllowAnonymous();
|
||||
}
|
||||
|
||||
public override async Task HandleAsync(CancellationToken ct)
|
||||
{
|
||||
StringBuilder responseBuilder = new();
|
||||
|
||||
responseBuilder.Append("ConnectionsAPI ©");
|
||||
if (DateTime.UtcNow.Year != START_YEAR)
|
||||
{
|
||||
responseBuilder.AppendFormat("{0} - {1}; ", START_YEAR, DateTime.UtcNow.Year);
|
||||
}
|
||||
else
|
||||
{
|
||||
responseBuilder.AppendFormat("{0}; ", DateTime.UtcNow.Year);
|
||||
}
|
||||
|
||||
responseBuilder.Append("by Mate Farkas; ");
|
||||
|
||||
responseBuilder.AppendFormat("v{0}-{1}+{2};",
|
||||
GitVersionInformation.MajorMinorPatch,
|
||||
GitVersionInformation.ShortSha,
|
||||
GitVersionInformation.EscapedBranchName);
|
||||
|
||||
await SendStringAsync(responseBuilder.ToString(), cancellation: ct);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user