Closed JonasLeetTheWay closed 3 months ago
Hello @JonasLeetTheWay,
Thank you for opening this issue.
Currently, we can only set global idempotency options for MinimalAPIs. However, I have prepared a possible solution using an IIdempotencyOptionsProvider
to provide the idempotency options based on our needs (IdempotentAPI.MinimalAPI v3.1.0-issue-73-01).
Could this work in your case?
For example, we could return the IIdempotencyOptions
based on the requested path.
public class IdempotencyOptionsProvider : IIdempotencyOptionsProvider
{
public IIdempotencyOptions GetIdempotencyOptions(IHttpContextAccessor httpContextAccessor)
{
switch (httpContextAccessor?.HttpContext?.Request.Path)
{
case "/v6/TestingIdempotentAPI/test":
return new IdempotencyOptions()
{
ExpireHours = 1,
};
}
return new IdempotencyOptions();
}
}
We will need to register IdempotencyOptionsProvider
in the Program.cs
:
builder.Services.AddIdempotentMinimalAPI(new IdempotencyOptionsProvider());
This issue is resolved in the following stable version:
For Minimal APIs, how to configure the idempotent options for a specific endpoint, not generally? (cache deadline, etc)
In controllers, we can use attribute to configure, but how about Minimal APIs?