@@ -40,7 +40,8 @@ public RouteActionProvider(IEndpointRouteBuilder builder, DashboardOptions optio
40
40
_agent = _serviceProvider . GetService < GatewayProxyAgent > ( ) ; // may be null
41
41
}
42
42
43
- private IMonitoringApi MonitoringApi => _serviceProvider . GetRequiredService < IDataStorage > ( ) . GetMonitoringApi ( ) ;
43
+ private IDataStorage DataStorage => _serviceProvider . GetRequiredService < IDataStorage > ( ) ;
44
+ private IMonitoringApi MonitoringApi => DataStorage . GetMonitoringApi ( ) ;
44
45
45
46
public void MapDashboardRoutes ( )
46
47
{
@@ -54,7 +55,9 @@ public void MapDashboardRoutes()
54
55
_builder . MapGet ( prefixMatch + "/published/message/{id:long}" , PublishedMessageDetails ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
55
56
_builder . MapGet ( prefixMatch + "/received/message/{id:long}" , ReceivedMessageDetails ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
56
57
_builder . MapPost ( prefixMatch + "/published/requeue" , PublishedRequeue ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
58
+ _builder . MapPost ( prefixMatch + "/published/delete" , PublishedDelete ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
57
59
_builder . MapPost ( prefixMatch + "/received/reexecute" , ReceivedRequeue ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
60
+ _builder . MapPost ( prefixMatch + "/received/delete" , ReceivedDelete ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
58
61
_builder . MapGet ( prefixMatch + "/published/{status}" , PublishedList ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
59
62
_builder . MapGet ( prefixMatch + "/received/{status}" , ReceivedList ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
60
63
_builder . MapGet ( prefixMatch + "/subscriber" , Subscribers ) . AllowAnonymousIf ( _options . AllowAnonymousExplicit , _options . AuthorizationPolicy ) ;
@@ -79,7 +82,7 @@ public async Task MetaInfo(HttpContext httpContext)
79
82
var cap = _serviceProvider . GetService < CapMarkerService > ( ) ;
80
83
var broker = _serviceProvider . GetService < CapMessageQueueMakerService > ( ) ;
81
84
var storage = _serviceProvider . GetService < CapStorageMarkerService > ( ) ;
82
-
85
+
83
86
await httpContext . Response . WriteAsJsonAsync ( new
84
87
{
85
88
cap ,
@@ -215,6 +218,23 @@ public async Task PublishedRequeue(HttpContext httpContext)
215
218
httpContext . Response . StatusCode = StatusCodes . Status204NoContent ;
216
219
}
217
220
221
+ public async Task PublishedDelete ( HttpContext httpContext )
222
+ {
223
+ if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
224
+
225
+ var messageIds = await httpContext . Request . ReadFromJsonAsync < long [ ] > ( ) ;
226
+ if ( messageIds == null || messageIds . Length == 0 )
227
+ {
228
+ httpContext . Response . StatusCode = StatusCodes . Status422UnprocessableEntity ;
229
+ return ;
230
+ }
231
+
232
+ foreach ( var messageId in messageIds )
233
+ _ = await DataStorage . DeletePublishedMessageAsync ( messageId ) ;
234
+
235
+ httpContext . Response . StatusCode = StatusCodes . Status204NoContent ;
236
+ }
237
+
218
238
public async Task ReceivedRequeue ( HttpContext httpContext )
219
239
{
220
240
if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
@@ -236,6 +256,24 @@ public async Task ReceivedRequeue(HttpContext httpContext)
236
256
httpContext . Response . StatusCode = StatusCodes . Status204NoContent ;
237
257
}
238
258
259
+ public async Task ReceivedDelete ( HttpContext httpContext )
260
+ {
261
+ if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
262
+
263
+ var messageIds = await httpContext . Request . ReadFromJsonAsync < long [ ] > ( ) ;
264
+ if ( messageIds == null || messageIds . Length == 0 )
265
+ {
266
+ httpContext . Response . StatusCode = StatusCodes . Status422UnprocessableEntity ;
267
+ return ;
268
+ }
269
+
270
+ foreach ( var messageId in messageIds )
271
+ _ = await DataStorage . DeleteReceivedMessageAsync ( messageId ) ;
272
+
273
+ httpContext . Response . StatusCode = StatusCodes . Status204NoContent ;
274
+ }
275
+
276
+
239
277
public async Task PublishedList ( HttpContext httpContext )
240
278
{
241
279
if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
@@ -293,7 +331,7 @@ public async Task ReceivedList(HttpContext httpContext)
293
331
public async Task Subscribers ( HttpContext httpContext )
294
332
{
295
333
if ( _agent != null && await _agent . Invoke ( httpContext ) ) return ;
296
-
334
+
297
335
var cache = _serviceProvider . GetRequiredService < MethodMatcherCache > ( ) ;
298
336
var subscribers = cache . GetCandidatesMethodsOfGroupNameGrouped ( ) ;
299
337
0 commit comments