Skip to content

Commit 8630742

Browse files
committed
add enabledetailederrors option
1 parent 6421eb1 commit 8630742

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

samples/Management/NegotiationServer/Controllers/NegotiateController.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@
55
using System.Threading.Tasks;
66
using Microsoft.AspNetCore.Mvc;
77
using Microsoft.Azure.SignalR.Management;
8+
using Microsoft.Extensions.Configuration;
89

910
namespace NegotiationServer.Controllers
1011
{
1112
[ApiController]
1213
public class NegotiateController : ControllerBase
1314
{
15+
private const string EnableDetailedErrors = "EnableDetailedErrors";
1416
private readonly ServiceHubContext _messageHubContext;
1517
private readonly ServiceHubContext _chatHubContext;
18+
private readonly bool _enableDetailedErrors;
1619

17-
public NegotiateController(IHubContextStore store)
20+
public NegotiateController(IHubContextStore store, IConfiguration configuration)
1821
{
1922
_messageHubContext = store.MessageHubContext;
2023
_chatHubContext = store.ChatHubContext;
24+
_enableDetailedErrors = configuration.GetValue(EnableDetailedErrors, false);
2125
}
2226

2327
[HttpPost("message/negotiate")]
@@ -42,8 +46,8 @@ private async Task<ActionResult> NegotiateBase(string user, ServiceHubContext se
4246

4347
var negotiateResponse = await serviceHubContext.NegotiateAsync(new()
4448
{
45-
UserId = user/*,
46-
EnableDetailedErrors = true*/
49+
UserId = user,
50+
EnableDetailedErrors = _enableDetailedErrors
4751
});
4852

4953
return new JsonResult(new Dictionary<string, string>()

samples/Management/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ dotnet user-secrets set Azure:SignalR:ConnectionString "<Connection String>"
1717
dotnet run
1818
```
1919

20+
> Parameters of `dotnet run`
21+
>
22+
> --enableDetailedErrors: true to enable log detailed errors on client side, false to disable. The default value is false, as detailed errors might contain sensitive information.
23+
2024
### Start SignalR clients
2125

2226
```

0 commit comments

Comments
 (0)