Closed CaptainPowerTurtle closed 4 months ago
Hello @CaptainPowerTurtle,
Thank you for opening this issue. I have not tried using it with FastEndpoints, but I will try to when I have some free time.
@ikyriak i'm the lead maintainer of fastendpoints and thought you might find the following info interesting:
so if there's any interest in adding FE support, you'd have to grab the response DTO instance from the HttpContext.Items
dictionary for storing in the cache, since the FE minimal api delegate doesn't return anything itself.
let me know if there's anything we can do from our end to facilitate compatibility.
thanks!
Hello @dj-nitehawk,
Thank you for providing me with this helpful information 🙏
Hello @dj-nitehawk,
When using Minimal APIs, in the InvokeAsync(EndpointFilterInvocationContext context, EndpointFilterDelegate next)
method on an IEndpointFilter
, I have access to the actual request class (e.g., the DTO in a POST request).
However, this is not available when using FastEndpoints
. Is there a way to get the request body?
This is needed not to accept the same idempotency key for different request payloads.
i see... the trouble is, the following is how fastendpoints registers the minimal api delegates for endpoints:
so, you won't have access to a typed request dto at the outer level of IEndpointFilter
s. the request dto is created inside FE's endpoint handler.
you could maybe read the request stream via HttpContext.Request.Body
for the purpose of building the cache-key. that is what we're doing in our idempotency implementation. which, may not work for you since our implementation is based on the OutputCaching middleware.
i'm assuming you need access to the request dto for building the cache-key by iterating the properties of the dto via reflection yes? in which case, i'm out of ideas 🤔
Thank you for your response, @dj-nitehawk. When FastEndpoints are used, I will read the request stream via HttpContext.Request.Body
. 🙏
Hello @CaptainPowerTurtle,
I have pushed the following prerelease versions that support FastEndpoints:
This issue is resolved in the following stable version:
Have anyone tried to use this with FastEndpoints?: https://fast-endpoints.com/
I followed the setup/examples for the minimal api, and it is almost working. It is caching the response, but when i call the endpoint again, using the same key, i get no data back.
I tested it with the MinimalApi endpoints, and it works as it should.