-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHealth.cs
More file actions
44 lines (37 loc) · 1.12 KB
/
Copy pathHealth.cs
File metadata and controls
44 lines (37 loc) · 1.12 KB
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System.Text.Json;
using System.Text.Json.Serialization;
using Microsoft.AspNetCore.Http;
namespace dnproto.pds.xrpc;
public class Health : BaseXrpcCommand
{
public IResult GetResponse()
{
IncrementStatistics();
//
// See if the code rev exists
//
string codeRevFilePath = Path.Combine(Pds.LocalFileSystem.GetDataDir(), "pds", "code-rev.txt");
if(File.Exists(codeRevFilePath))
{
var codeRev = File.ReadAllText(codeRevFilePath).Trim();
string version = $"dnproto {codeRev}";
if(!string.IsNullOrEmpty(codeRev))
{
return Results.Json(new { version = version }, contentType: "application/json");
}
}
//
// Otherwise, return the default version from config
//
var health = new HealthResponse
{
Version = "dnproto 0.0.005"
};
return Results.Json(health, contentType: "application/json");
}
}
public class HealthResponse
{
[JsonPropertyName("version")]
public string Version { get; set; } = string.Empty;
}