forked from microsoft/kernel-memory
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWebAPIEndpoints.cs
More file actions
583 lines (522 loc) · 28.8 KB
/
WebAPIEndpoints.cs
File metadata and controls
583 lines (522 loc) · 28.8 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
// Copyright (c) Microsoft. All rights reserved.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Http.HttpResults;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.Logging;
using Microsoft.KernelMemory.Configuration;
using Microsoft.KernelMemory.Context;
using Microsoft.KernelMemory.Diagnostics;
using Microsoft.KernelMemory.DocumentStorage;
using Microsoft.KernelMemory.HTTP;
using Microsoft.KernelMemory.Service.AspNetCore.Models;
using Microsoft.OpenApi.Models;
namespace Microsoft.KernelMemory.Service.AspNetCore;
public static class WebAPIEndpoints
{
public static IEndpointRouteBuilder AddKernelMemoryEndpoints(
this IEndpointRouteBuilder builder,
string apiPrefix = "/",
KernelMemoryConfig? kmConfig = null,
IEndpointFilter[]? filters = null)
{
builder.AddPostUploadEndpoint(apiPrefix, kmConfig?.Service.GetMaxUploadSizeInBytes()).AddFilters(filters);
builder.AddUploadStatusEndpoint(apiPrefix).AddFilters(filters);
builder.AddAskEndpoint(apiPrefix, kmConfig?.Service.SendSSEDoneMessage ?? true).AddFilters(filters);
builder.AddSearchEndpoint(apiPrefix).AddFilters(filters);
builder.AddGetDownloadEndpoint(apiPrefix).AddFilters(filters);
builder.AddListIndexesEndpoint(apiPrefix).AddFilters(filters);
builder.AddDeleteIndexEndpoint(apiPrefix).AddFilters(filters);
builder.AddDeleteDocumentEndpoint(apiPrefix).AddFilters(filters);
return builder;
}
public static RouteHandlerBuilder AddPostUploadEndpoint(
this IEndpointRouteBuilder builder,
string apiPrefix = "/",
long? maxUploadSizeInBytes = null)
{
RouteGroupBuilder group = builder.MapGroup(apiPrefix);
// File upload endpoint
var route = group.MapPost(Constants.HttpUploadEndpoint, async Task<IResult> (
HttpRequest request,
IKernelMemory service,
ILogger<KernelMemoryWebAPI> log,
IContextProvider contextProvider,
CancellationToken cancellationToken) =>
{
if (maxUploadSizeInBytes.HasValue && request.HttpContext.Features.Get<IHttpMaxRequestBodySizeFeature>() is { } feature)
{
log.LogTrace("Max upload request body size set to {MaxSize} bytes", maxUploadSizeInBytes.Value);
feature.MaxRequestBodySize = maxUploadSizeInBytes;
}
log.LogTrace("New upload HTTP request, content length {ContentLength}", request.ContentLength);
// Note: .NET doesn't yet support binding multipart forms including data and files
(HttpDocumentUploadRequest input, bool isValid, string errMsg)
= await HttpDocumentUploadRequest.BindHttpRequestAsync(request, cancellationToken)
.ConfigureAwait(false);
// Allow internal classes to access custom arguments via IContextProvider
contextProvider.InitContextArgs(input.ContextArguments);
log.LogTrace("Index '{IndexName}'", input.Index.NLF()); //lgtm[cs/log-forging]
if (!isValid)
{
log.LogError(errMsg);
return Results.Problem(detail: errMsg, statusCode: 400);
}
try
{
// UploadRequest => Document
var documentId = await service
.ImportDocumentAsync(input.ToDocumentUploadRequest(), contextProvider.GetContext(), cancellationToken)
.ConfigureAwait(false);
log.LogTrace("Doc Id '{DocumentId}'", documentId.NLF()); //lgtm[cs/log-forging]
var url = Constants.HttpUploadStatusEndpointWithParams
.Replace(Constants.HttpIndexPlaceholder, input.Index, StringComparison.Ordinal)
.Replace(Constants.HttpDocumentIdPlaceholder, documentId, StringComparison.Ordinal);
return Results.Accepted(url, new UploadAccepted
{
DocumentId = documentId,
Index = input.Index,
Message = "Document upload completed, ingestion pipeline started"
});
}
catch (Exception e)
{
return Results.Problem(title: "Document upload failed", detail: e.Message, statusCode: 503);
}
})
.WithName("UploadDocument")
.WithDisplayName("UploadDocument")
.WithOpenApi(
operation =>
{
operation.Summary = "Upload a new document to the knowledge base";
operation.Description = "Upload a document consisting of one or more files to extract memories from. The extraction process happens asynchronously. If a document with the same ID already exists, it will be overwritten and the memories previously extracted will be updated.";
operation.RequestBody = new OpenApiRequestBody
{
Content =
{
["multipart/form-data"] = new OpenApiMediaType
{
Schema = new OpenApiSchema
{
Type = "object",
Properties =
{
["index"] = new OpenApiSchema
{
Type = "string",
Description = "Name of the index where to store memories generated by the files."
},
["documentId"] = new OpenApiSchema
{
Type = "string",
Description = "Unique ID used for import pipeline and document ID."
},
["tags"] = new OpenApiSchema
{
Type = "object",
AdditionalProperties = new OpenApiSchema { Type = "string" },
Description = "Tags to apply to the memories extracted from the files."
},
["steps"] = new OpenApiSchema
{
Type = "array",
Items = new OpenApiSchema { Type = "string" },
Description = "How to process the files, e.g. how to extract/chunk etc."
},
["files"] = new OpenApiSchema
{
Type = "array",
Items = new OpenApiSchema
{
Type = "string",
Format = "binary"
},
Description = "Files to process and extract memories from."
}
}
}
}
},
Description = "Document to upload and extract memories from"
};
return operation;
}
)
.Produces<UploadAccepted>(StatusCodes.Status202Accepted)
.Produces<ProblemDetails>(StatusCodes.Status400BadRequest)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden)
.Produces<ProblemDetails>(StatusCodes.Status503ServiceUnavailable);
return route;
}
public static RouteHandlerBuilder AddListIndexesEndpoint(
this IEndpointRouteBuilder builder, string apiPrefix = "/")
{
RouteGroupBuilder group = builder.MapGroup(apiPrefix);
// List of indexes endpoint
var route = group.MapGet(Constants.HttpIndexesEndpoint,
async Task<IResult> (
IKernelMemory service,
ILogger<KernelMemoryWebAPI> log,
CancellationToken cancellationToken) =>
{
log.LogTrace("New index list HTTP request");
var result = new IndexCollection();
IEnumerable<IndexDetails> list = await service.ListIndexesAsync(cancellationToken)
.ConfigureAwait(false);
foreach (IndexDetails index in list)
{
result.Results.Add(index);
}
return Results.Ok(result);
})
.WithName("ListIndexes")
.WithDisplayName("ListIndexes")
.WithDescription("Get the list of containers (aka 'indexes') from the knowledge base.")
.WithSummary("Get the list of containers (aka 'indexes') from the knowledge base. Each index has a unique name. Indexes are collections of memories extracted from the documents uploaded.")
.Produces<IndexCollection>(StatusCodes.Status200OK)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden);
return route;
}
public static RouteHandlerBuilder AddDeleteIndexEndpoint(
this IEndpointRouteBuilder builder, string apiPrefix = "/", IEndpointFilter[]? filters = null)
{
RouteGroupBuilder group = builder.MapGroup(apiPrefix);
// Delete index endpoint
var route = group.MapDelete(Constants.HttpIndexesEndpoint,
async Task<IResult> (
[FromQuery(Name = Constants.WebService.IndexField)]
string? index,
IKernelMemory service,
ILogger<KernelMemoryWebAPI> log,
CancellationToken cancellationToken) =>
{
log.LogTrace("New delete document HTTP request, index '{IndexName}'", index.NLF()); //lgtm[cs/log-forging]
await service.DeleteIndexAsync(index: index, cancellationToken)
.ConfigureAwait(false);
// There's no API to check the index deletion progress, so the URL is empty
var url = string.Empty;
return Results.Accepted(url, new DeleteAccepted
{
Index = index ?? string.Empty,
Message = "Index deletion request received, pipeline started"
});
})
.WithName("DeleteIndexByName")
.WithDisplayName("DeleteIndexByName")
.WithDescription("Delete a container of documents (aka 'index') from the knowledge base.")
.WithSummary("Delete a container of documents (aka 'index') from the knowledge base. Indexes are collections of memories extracted from the documents uploaded.")
.Produces<DeleteAccepted>(StatusCodes.Status202Accepted)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden);
return route;
}
public static RouteHandlerBuilder AddDeleteDocumentEndpoint(
this IEndpointRouteBuilder builder, string apiPrefix = "/", IEndpointFilter[]? filters = null)
{
RouteGroupBuilder group = builder.MapGroup(apiPrefix);
// Delete document endpoint
var route = group.MapDelete(Constants.HttpDocumentsEndpoint,
async Task<IResult> (
[FromQuery(Name = Constants.WebService.IndexField)]
string? index,
[FromQuery(Name = Constants.WebService.DocumentIdField)]
string documentId,
IKernelMemory service,
ILogger<KernelMemoryWebAPI> log,
CancellationToken cancellationToken) =>
{
log.LogTrace("New delete document HTTP request, index '{IndexName}'", index.NLF()); //lgtm[cs/log-forging]
await service.DeleteDocumentAsync(documentId: documentId, index: index, cancellationToken)
.ConfigureAwait(false);
var url = Constants.HttpUploadStatusEndpointWithParams
.Replace(Constants.HttpIndexPlaceholder, index, StringComparison.Ordinal)
.Replace(Constants.HttpDocumentIdPlaceholder, documentId, StringComparison.Ordinal);
return Results.Accepted(url, new DeleteAccepted
{
DocumentId = documentId,
Index = index ?? string.Empty,
Message = "Document deletion request received, pipeline started"
});
})
.WithName("DeleteDocumentById")
.WithDisplayName("DeleteDocumentById")
.WithDescription("Delete a document from the knowledge base.")
.WithSummary("Delete a document from the knowledge base. When deleting a document, which can consist of multiple files, all the memories previously extracted are deleted too.")
.Produces<DeleteAccepted>(StatusCodes.Status202Accepted)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden);
return route;
}
public static RouteHandlerBuilder AddAskEndpoint(
this IEndpointRouteBuilder builder, string apiPrefix = "/", bool sseSendDoneMessage = true, IEndpointFilter[]? filters = null)
{
RouteGroupBuilder group = builder.MapGroup(apiPrefix);
// Ask endpoint
var route = group.MapPost(Constants.HttpAskEndpoint,
async Task (
HttpContext httpContext,
MemoryQuery query,
IKernelMemory service,
ILogger<KernelMemoryWebAPI> log,
IContextProvider contextProvider,
CancellationToken cancellationToken) =>
{
// Allow internal classes to access custom arguments via IContextProvider
contextProvider.InitContextArgs(query.ContextArguments);
log.LogTrace("New ask request, index '{IndexName}', minRelevance {MinRelevance}",
query.Index.NLF(), query.MinRelevance); //lgtm[cs/log-forging]
IAsyncEnumerable<MemoryAnswer> answerStream = service.AskStreamingAsync(
question: query.Question,
index: query.Index,
filters: query.Filters,
minRelevance: query.MinRelevance,
options: new SearchOptions { Stream = query.Stream },
context: contextProvider.GetContext(),
cancellationToken: cancellationToken);
httpContext.Response.StatusCode = StatusCodes.Status200OK;
try
{
if (query.Stream)
{
httpContext.Response.ContentType = "text/event-stream; charset=utf-8";
await foreach (var answer in answerStream.ConfigureAwait(false))
{
string json = answer.ToJson(true);
await httpContext.Response.WriteAsync($"{SSE.DataPrefix}{json}\n\n", cancellationToken).ConfigureAwait(false);
await httpContext.Response.Body.FlushAsync(cancellationToken).ConfigureAwait(false);
}
}
else
{
httpContext.Response.ContentType = "application/json; charset=utf-8";
MemoryAnswer answer = await answerStream.FirstAsync(cancellationToken: cancellationToken).ConfigureAwait(false);
string json = answer.ToJson(false);
await httpContext.Response.WriteAsync(json, cancellationToken).ConfigureAwait(false);
}
}
catch (Exception e)
{
log.LogError(e, "An error occurred while preparing the response");
// Attempt to set the status code, in case the output hasn't started yet
httpContext.Response.StatusCode = StatusCodes.Status503ServiceUnavailable;
var json = query.Stream
? JsonSerializer.Serialize(new MemoryAnswer
{
StreamState = StreamStates.Error,
Question = query.Question,
NoResult = true,
NoResultReason = $"Error: {e.Message} [{e.GetType().FullName}]"
})
: JsonSerializer.Serialize(new ProblemDetails
{
Status = StatusCodes.Status503ServiceUnavailable,
Title = "Service Unavailable",
Detail = $"{e.Message} [{e.GetType().FullName}]"
});
await httpContext.Response.WriteAsync(query.Stream ? $"{SSE.DataPrefix}{json}\n\n" : json, cancellationToken).ConfigureAwait(false);
}
if (query.Stream && sseSendDoneMessage)
{
await httpContext.Response.WriteAsync($"{SSE.DoneMessage}\n\n", cancellationToken: cancellationToken).ConfigureAwait(false);
}
await httpContext.Response.Body.FlushAsync(cancellationToken).ConfigureAwait(false);
})
.WithName("AnswerQuestion")
.WithDisplayName("AnswerQuestion")
.WithDescription("Answer a user question using the internal knowledge base.")
.WithSummary("Use the memories extracted from the files uploaded to generate an answer. The query can include filters to use only a subset of the memories available.")
.Produces<MemoryAnswer>(StatusCodes.Status200OK)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden)
.Produces<ProblemDetails>(StatusCodes.Status503ServiceUnavailable);
return route;
}
public static RouteHandlerBuilder AddSearchEndpoint(
this IEndpointRouteBuilder builder, string apiPrefix = "/", IEndpointFilter[]? filters = null)
{
RouteGroupBuilder group = builder.MapGroup(apiPrefix);
// Search endpoint
var route = group.MapPost(Constants.HttpSearchEndpoint,
async Task<IResult> (
SearchQuery query,
IKernelMemory service,
ILogger<KernelMemoryWebAPI> log,
IContextProvider contextProvider,
CancellationToken cancellationToken) =>
{
// Allow internal classes to access custom arguments via IContextProvider
contextProvider.InitContextArgs(query.ContextArguments);
log.LogTrace("New search HTTP request, index '{IndexName}', minRelevance {MinRelevance}",
query.Index.NLF(), query.MinRelevance); //lgtm[cs/log-forging]
SearchResult answer = await service.SearchAsync(
query: query.Query,
index: query.Index,
filters: query.Filters,
minRelevance: query.MinRelevance,
limit: query.Limit,
context: contextProvider.GetContext(),
cancellationToken: cancellationToken)
.ConfigureAwait(false);
return Results.Ok(answer);
})
.WithName("SearchDocumentSnippets")
.WithDisplayName("SearchDocumentSnippets")
.WithDescription("Search the knowledge base for relevant snippets of text.")
.WithSummary("Search the knowledge base for relevant snippets of text. The search can include filters to use only a subset of the knowledge base.")
.Produces<SearchResult>(StatusCodes.Status200OK)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden);
return route;
}
public static RouteHandlerBuilder AddUploadStatusEndpoint(
this IEndpointRouteBuilder builder, string apiPrefix = "/", IEndpointFilter[]? filters = null)
{
RouteGroupBuilder group = builder.MapGroup(apiPrefix);
// Document status endpoint
var route = group.MapGet(Constants.HttpUploadStatusEndpoint,
async Task<IResult> (
[FromQuery(Name = Constants.WebService.IndexField)]
string? index,
[FromQuery(Name = Constants.WebService.DocumentIdField)]
string documentId,
IKernelMemory memoryClient,
ILogger<KernelMemoryWebAPI> log,
CancellationToken cancellationToken) =>
{
log.LogTrace("New document status HTTP request");
if (string.IsNullOrEmpty(documentId))
{
return Results.Problem(detail: $"'{Constants.WebService.DocumentIdField}' query parameter is missing or has no value", statusCode: 400);
}
DataPipelineStatus? pipeline = await memoryClient.GetDocumentStatusAsync(documentId: documentId, index: index, cancellationToken)
.ConfigureAwait(false);
if (pipeline == null)
{
return Results.Problem(detail: "Document not found", statusCode: 404);
}
if (pipeline.Empty)
{
return Results.Problem(detail: "Empty pipeline", statusCode: 404);
}
return Results.Ok(pipeline);
})
.WithName("CheckDocumentStatus")
.WithDisplayName("CheckDocumentStatus")
.WithDescription("Check the status of a file upload in progress.")
.WithSummary("Check the status of a file upload in progress. When uploading a document, which can consist of multiple files, each file goes through multiple steps. The status include details about which steps are completed.")
.Produces<DataPipelineStatus>(StatusCodes.Status200OK)
.Produces<ProblemDetails>(StatusCodes.Status400BadRequest)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden)
.Produces<ProblemDetails>(StatusCodes.Status404NotFound)
.Produces<ProblemDetails>(StatusCodes.Status413PayloadTooLarge);
return route;
}
public static RouteHandlerBuilder AddGetDownloadEndpoint(
this IEndpointRouteBuilder builder, string apiPrefix = "/", IEndpointFilter[]? filters = null)
{
RouteGroupBuilder group = builder.MapGroup(apiPrefix);
// File download endpoint
var route = group.MapGet(Constants.HttpDownloadEndpoint, async Task<IResult> (
[FromQuery(Name = Constants.WebService.IndexField)]
string? index,
[FromQuery(Name = Constants.WebService.DocumentIdField)]
string documentId,
[FromQuery(Name = Constants.WebService.FilenameField)]
string filename,
HttpContext httpContext,
IKernelMemory service,
ILogger<KernelMemoryWebAPI> log,
CancellationToken cancellationToken) =>
{
var isValid = !(
string.IsNullOrWhiteSpace(documentId) ||
string.IsNullOrWhiteSpace(filename));
var errMsg = "Missing required parameter";
log.LogTrace("New download file HTTP request, index {IndexName}, documentId {DocumentId}, fileName {FileName}",
index.NLF(), documentId.NLF(), filename.NLF()); //lgtm[cs/log-forging]
if (!isValid)
{
log.LogError(errMsg);
return Results.Problem(detail: errMsg, statusCode: 400);
}
try
{
// DownloadRequest => Document
var file = await service.ExportFileAsync(
documentId: documentId,
fileName: filename,
index: index,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
if (file == null)
{
log.LogWarning("Returned file is NULL, file not found");
return Results.Problem(title: "File not found", statusCode: 404);
}
log.LogTrace("Downloading file '{FileName}', size '{FileSize}', type '{FileType}'",
filename.NLF(), file.FileSize, file.FileType.NLF()); //lgtm[cs/log-forging]
Stream resultingFileStream = await file.GetStreamAsync().WaitAsync(cancellationToken).ConfigureAwait(false);
var response = Results.Stream(
resultingFileStream,
contentType: file.FileType,
fileDownloadName: filename,
lastModified: file.LastWrite,
enableRangeProcessing: true);
// Add content length header if missing
if (response is FileStreamHttpResult { FileLength: null or 0 })
{
httpContext.Response.Headers.ContentLength = file.FileSize;
}
return response;
}
catch (DocumentStorageFileNotFoundException e)
{
return Results.Problem(title: "File not found", detail: e.Message, statusCode: 404);
}
catch (Exception e)
{
return Results.Problem(title: "File download failed", detail: e.Message, statusCode: 503);
}
})
.WithName("DownloadFile")
.WithDisplayName("DownloadFile")
.WithDescription("Download a file referenced by a previous answer or search result.")
.WithSummary("Download a file referenced by a previous answer or search result. The file is returned as the original copy, retrieved from the document storage.")
.WithGroupName("Search")
.Produces<StreamableFileContent>(StatusCodes.Status200OK)
.Produces<ProblemDetails>(StatusCodes.Status404NotFound)
.Produces<ProblemDetails>(StatusCodes.Status401Unauthorized)
.Produces<ProblemDetails>(StatusCodes.Status403Forbidden)
.Produces<ProblemDetails>(StatusCodes.Status503ServiceUnavailable);
return route;
}
#pragma warning disable CA1812 // used by logger, can't be static
// Class used to tag log entries and allow log filtering
// ReSharper disable once ClassNeverInstantiated.Local
private sealed class KernelMemoryWebAPI;
#pragma warning restore CA1812
}
internal static class EndpointConventionBuilderExtensions
{
internal static void AddFilters(this IEndpointConventionBuilder route, IEndpointFilter[]? filters = null)
{
if (filters == null || filters.Length == 0) { return; }
foreach (var filter in filters)
{
route.AddEndpointFilter(filter);
}
}
}