-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Support for route handler filters in minimal APIs issue #41188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I've just come across this too, but with For example, the filter is added here: // Get all Todo items
builder.MapGet("/api/items", async (
ClaimsPrincipal user,
ITodoService service,
CancellationToken cancellationToken) =>
{
return Results.Ok(await service.GetListAsync(user.GetUserId(), cancellationToken));
})
.AddFilter<RateLimitFilter>()
.ProducesProblem(StatusCodes.Status429TooManyRequests)
.RequireAuthorization(); The var rateLimit = GetRateLimitPolicy(userId, operation);
try
{
return await rateLimit.ExecuteAsync(async () => await next(context));
}
catch (RateLimitRejectedException ex)
{
return Results.Extensions.RateLimited(ex.RetryAfter);
}
|
Right, because the issue is with the generated code and how we handle inline delegates vs. methods. So the workaround until preivew4 is to move your handler code into a method. |
Uh oh!
There was an error while loading. Please reload this page.
.net version is 7.0.100-preview.3.22179.4
The following code will work:
But the following code doesn't work:
System.NullReferenceException:“Object reference not set to an instance of an object.”
The text was updated successfully, but these errors were encountered: