-
Notifications
You must be signed in to change notification settings - Fork 51
Expand file tree
/
Copy pathConnectionController.cs
More file actions
55 lines (51 loc) · 1.9 KB
/
Copy pathConnectionController.cs
File metadata and controls
55 lines (51 loc) · 1.9 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
namespace ServiceControl.Audit.Connection
{
using System.Text.Json;
using Infrastructure.Settings;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using ServiceControl.Infrastructure.Auth;
[ApiController]
[Route("api")]
public class ConnectionController(Settings settings) : ControllerBase
{
// This controller doesn't use the default serialization settings because
// ServicePulse and the Platform Connector Plugin expect the connection
// details the be serialized and formatted in a specific way
[Authorize(Policy = Permissions.AuditConnectionView)]
[Route("connection")]
[HttpGet]
public IActionResult GetConnectionDetails() =>
new JsonResult(
new ConnectionDetails
{
MessageAudit = new MessageAuditConnectionDetails
{
Enabled = true,
AuditQueue = settings.AuditQueue
},
SagaAudit = new SagaAuditConnectionDetails
{
Enabled = true,
SagaAuditQueue = settings.AuditQueue,
}
}, JsonSerializerOptions.Default);
}
public class ConnectionDetails
{
public MessageAuditConnectionDetails MessageAudit { get; set; }
public SagaAuditConnectionDetails SagaAudit { get; set; }
}
// HINT: This should match the type in the PlatformConnector package
public class MessageAuditConnectionDetails
{
public bool Enabled { get; set; }
public string AuditQueue { get; set; }
}
// HINT: This should match the type in the PlatformConnector package
public class SagaAuditConnectionDetails
{
public bool Enabled { get; set; }
public string SagaAuditQueue { get; set; }
}
}