@@ -20,15 +20,10 @@ namespace Synapse.Api.Http;
20
20
/// <param name="mediator">The service used to mediate calls</param>
21
21
/// <param name="jsonSerializer">The service used to serialize/deserialize data to/from JSON</param>
22
22
public abstract class NamespacedResourceController < TResource > ( IMediator mediator , IJsonSerializer jsonSerializer )
23
- : ResourceController < TResource > ( mediator )
23
+ : ResourceController < TResource > ( mediator , jsonSerializer )
24
24
where TResource : class , IResource , new ( )
25
25
{
26
26
27
- /// <summary>
28
- /// Gets the service used to serialize/deserialize data to/from JSON
29
- /// </summary>
30
- protected IJsonSerializer JsonSerializer { get ; } = jsonSerializer ;
31
-
32
27
/// <summary>
33
28
/// Gets the resource with the specified name and namespace
34
29
/// </summary>
@@ -150,13 +145,17 @@ public virtual async Task<IAsyncEnumerable<IResourceWatchEvent<TResource>>> Watc
150
145
/// <param name="namespace">The namespace the resources to watch belong to</param>
151
146
/// <param name="labelSelector">A comma-separated list of label selectors, if any</param>
152
147
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
153
- /// <returns>A new <see cref="IActionResult "/></returns>
148
+ /// <returns>A new awaitable <see cref="Task "/></returns>
154
149
[ HttpGet ( "{namespace}/watch/sse" ) ]
155
150
[ ProducesResponseType ( typeof ( IAsyncEnumerable < ResourceWatchEvent > ) , ( int ) HttpStatusCode . OK ) ]
156
151
[ ProducesErrorResponseType ( typeof ( Neuroglia . ProblemDetails ) ) ]
157
- public virtual async Task < IActionResult > WatchResourcesUsingSSE ( string @namespace , string ? labelSelector = null , CancellationToken cancellationToken = default )
152
+ public virtual async Task WatchResourcesUsingSSE ( string @namespace , string ? labelSelector = null , CancellationToken cancellationToken = default )
158
153
{
159
- if ( ! this . TryParseLabelSelectors ( labelSelector , out var labelSelectors ) ) return this . InvalidLabelSelector ( labelSelector ! ) ;
154
+ if ( ! this . TryParseLabelSelectors ( labelSelector , out var labelSelectors ) )
155
+ {
156
+ await WriteInvalidLabelSelectorResponseAsync ( labelSelector ! , cancellationToken ) . ConfigureAwait ( false ) ;
157
+ return ;
158
+ }
160
159
var response = await this . Mediator . ExecuteAsync ( new WatchResourcesQuery < TResource > ( @namespace , labelSelectors ) , cancellationToken ) . ConfigureAwait ( false ) ;
161
160
this . Response . Headers . ContentType = "text/event-stream" ;
162
161
this . Response . Headers . CacheControl = "no-cache" ;
@@ -172,7 +171,6 @@ public virtual async Task<IActionResult> WatchResourcesUsingSSE(string @namespac
172
171
}
173
172
}
174
173
catch ( Exception ex ) when ( ex is TaskCanceledException || ex is OperationCanceledException ) { }
175
- return this . Ok ( ) ;
176
174
}
177
175
178
176
/// <summary>
@@ -197,11 +195,11 @@ public virtual async Task<IAsyncEnumerable<IResourceWatchEvent<TResource>>> Moni
197
195
/// <param name="namespace">The namespace the resource to monitor belongs to</param>
198
196
/// <param name="name">The name of the resource to monitor</param>
199
197
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
200
- /// <returns>A new <see cref="IActionResult "/></returns>
198
+ /// <returns>A new awaitable <see cref="Task "/></returns>
201
199
[ HttpGet ( "{namespace}/{name}/monitor/sse" ) ]
202
200
[ ProducesResponseType ( typeof ( IAsyncEnumerable < ResourceWatchEvent > ) , ( int ) HttpStatusCode . OK ) ]
203
201
[ ProducesErrorResponseType ( typeof ( Neuroglia . ProblemDetails ) ) ]
204
- public virtual async Task < IActionResult > MonitorResourceUsingSSE ( string name , string @namespace , CancellationToken cancellationToken = default )
202
+ public virtual async Task MonitorResourceUsingSSE ( string name , string @namespace , CancellationToken cancellationToken = default )
205
203
{
206
204
var response = await this . Mediator . ExecuteAsync ( new MonitorResourceQuery < TResource > ( name , @namespace ) , cancellationToken ) . ConfigureAwait ( false ) ;
207
205
this . Response . Headers . ContentType = "text/event-stream" ;
@@ -218,7 +216,6 @@ public virtual async Task<IActionResult> MonitorResourceUsingSSE(string name, st
218
216
}
219
217
}
220
218
catch ( Exception ex ) when ( ex is TaskCanceledException || ex is OperationCanceledException ) { }
221
- return this . Ok ( ) ;
222
219
}
223
220
224
221
/// <summary>
0 commit comments