-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathRootController.cs
More file actions
100 lines (91 loc) · 3.27 KB
/
RootController.cs
File metadata and controls
100 lines (91 loc) · 3.27 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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
namespace ServiceControl.Audit.Infrastructure.WebApi
{
using Configuration;
using Microsoft.AspNetCore.Http.Extensions;
using Microsoft.AspNetCore.Mvc;
using Settings;
[ApiController]
[Route("api")]
public class RootController : ControllerBase
{
public RootController(Settings settings)
{
this.settings = settings;
}
[Route("")]
[HttpGet]
public OkObjectResult Urls()
{
var baseUrl = Request.GetDisplayUrl();
if (!baseUrl.EndsWith('/'))
{
baseUrl += "/";
}
var model = new RootUrls
{
KnownEndpointsUrl = "/endpoints/known", // relative URI to allow proxying
MessageSearchUrl = baseUrl + "messages/search/{keyword}/{?page,per_page,direction,sort}",
EndpointsMessageSearchUrl = baseUrl + "endpoints/{name}/messages/search/{keyword}/{?page,per_page,direction,sort}",
EndpointsMessagesUrl = baseUrl + "endpoints/{name}/messages/{?page,per_page,direction,sort}",
AuditCountUrl = baseUrl + "endpoints/{name}/audit-count",
Name = SettingsReader.Read(Settings.SettingsRootNamespace, "Name", "ServiceControl.Audit"),
Description = SettingsReader.Read(Settings.SettingsRootNamespace, "Description", "The audit backend for the Particular Service Platform"),
Configuration = baseUrl + "configuration"
};
return Ok(model);
}
[Route("instance-info")]
[Route("configuration")]
[HttpGet]
public OkObjectResult Config()
{
object content = new
{
Host = new
{
settings.InstanceName,
Logging = new
{
settings.LoggingSettings.LogPath,
LoggingLevel = settings.LoggingSettings.LogLevel
}
},
DataRetention = new
{
settings.AuditRetentionPeriod
},
PerformanceTunning = new
{
settings.MaxBodySizeToStore,
},
Transport = new
{
settings.TransportType,
settings.AuditLogQueue,
settings.AuditQueue,
settings.ForwardAuditMessages
},
Peristence = new
{
settings.PersistenceType
},
Plugins = new
{
}
};
return Ok(content);
}
readonly Settings settings;
public class RootUrls
{
public string Description { get; set; }
public string KnownEndpointsUrl { get; set; }
public string EndpointsMessageSearchUrl { get; set; }
public string EndpointsMessagesUrl { get; set; }
public string AuditCountUrl { get; set; }
public string Configuration { get; set; }
public string MessageSearchUrl { get; set; }
public string Name { get; set; }
}
}
}