[backend/web] Add version endpoint
This commit is contained in:
parent
3ad40f8d2e
commit
69f0727138
2 changed files with 43 additions and 0 deletions
33
Iceshrimp.Backend/Controllers/Web/VersionController.cs
Normal file
33
Iceshrimp.Backend/Controllers/Web/VersionController.cs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Mime;
|
||||||
|
using Iceshrimp.Backend.Controllers.Shared.Attributes;
|
||||||
|
using Iceshrimp.Backend.Core.Middleware;
|
||||||
|
using Iceshrimp.Shared.Helpers;
|
||||||
|
using Iceshrimp.Shared.Schemas.Web;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.RateLimiting;
|
||||||
|
|
||||||
|
namespace Iceshrimp.Backend.Controllers.Web;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Authenticate]
|
||||||
|
[EnableRateLimiting("sliding")]
|
||||||
|
[Route("/api/iceshrimp/version")]
|
||||||
|
[Produces(MediaTypeNames.Application.Json)]
|
||||||
|
public class VersionController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet]
|
||||||
|
[ProducesResults(HttpStatusCode.OK)]
|
||||||
|
public Task<VersionResponse> GetVersion()
|
||||||
|
{
|
||||||
|
var version = VersionHelpers.GetVersionInfo();
|
||||||
|
return Task.FromResult(new VersionResponse
|
||||||
|
{
|
||||||
|
Codename = version.Codename,
|
||||||
|
CommitHash = version.CommitHash,
|
||||||
|
Edition = version.Edition,
|
||||||
|
Version = version.Version,
|
||||||
|
RawVersion = version.RawVersion
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
10
Iceshrimp.Shared/Schemas/Web/VersionResponse.cs
Normal file
10
Iceshrimp.Shared/Schemas/Web/VersionResponse.cs
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
namespace Iceshrimp.Shared.Schemas.Web;
|
||||||
|
|
||||||
|
public class VersionResponse
|
||||||
|
{
|
||||||
|
public required string Codename { get; set; }
|
||||||
|
public required string Edition { get; set; }
|
||||||
|
public required string? CommitHash { get; set; }
|
||||||
|
public required string RawVersion { get; set; }
|
||||||
|
public required string Version { get; set; }
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue