diff --git a/ConnectionsAPI.csproj b/ConnectionsAPI.csproj index 1f02ff4..ee78d84 100644 --- a/ConnectionsAPI.csproj +++ b/ConnectionsAPI.csproj @@ -12,6 +12,9 @@ + + all + diff --git a/Features/Version/Get/GetVersionEndpoint.cs b/Features/Version/Get/GetVersionEndpoint.cs new file mode 100644 index 0000000..74c33f8 --- /dev/null +++ b/Features/Version/Get/GetVersionEndpoint.cs @@ -0,0 +1,40 @@ + +using System.Text; + +namespace ConnectionsAPI.Features.Version.Get +{ + public class GetVersionEndpoint : EndpointWithoutRequest + { + 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); + } + } +}