Closed shawnwildermuth closed 10 months ago
Hi Shawn, this looks good to me! :) I agree on not going for the EndpointFilter approach at this moment. This may be something to consider when .NET 6 goes out of support (I try to follow that release schedule regarding the versions this package should keep supporting) & the compiler directive won't be needed anymore.
FYI, pre-release: https://www.nuget.org/packages/Marvin.Cache.Headers/7.1.0-beta
This is a real fix to the minimal api support. Evidently the
IAsyncResourceFilter
isn't supported outside of MVC. So I had to inject the attributes during the request. To support this, I created two interfaces:IModelOptions
- a marker interface for the different options that can be retrieved from the attirbute.IModelOptionsProvider
- to provide a method for retrieving the options from the attribute.Added code to add a request delegate for the endpoint (if it is a
IModelOptionsProvider
- otherwise we don't need it) and after injecting the data into the HttpContext items, I call the default request delegate. Essentially injecting this code into hte pipeline.Caveat:
We might able to implement this cleaner with an EndpointFilter but that is only support in .NET 7+. Unless you're building specific versions for .NET 6, 7 and 8 - I didn't feel comfortable adding
#if NET7_OR_GREATER
into the codebase.Let me know what you think!