aboutsummaryrefslogtreecommitdiffstats
path: root/code/api/src/Endpoints/Internal/Root/GetApplicationVersionRoute.cs
blob: 34180d18aace0942474430e70ecb4cd2ccba5389 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
namespace IOL.GreatOffice.Api.Endpoints.Internal.Root;

public class GetApplicationVersionRoute : RouteBaseSync.WithoutRequest.WithActionResult<string>
{
    private readonly IWebHostEnvironment _environment;

    public GetApplicationVersionRoute(IWebHostEnvironment environment) {
        _environment = environment;
    }

    /// <summary>
    /// Get the running api version number.
    /// </summary>
    /// <returns></returns>
    [HttpGet("~/_/version")]
    public override ActionResult<string> Handle() {
        var versionFilePath = Path.Combine(_environment.WebRootPath, "version.txt");
        return Ok(System.IO.File.ReadAllText(versionFilePath));
    }
}