Skip to content
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

updates to support non-mvc http header attributes #135

Merged
merged 2 commits into from
Jan 14, 2024

Conversation

shawnwildermuth
Copy link
Contributor

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!

@KevinDockx
Copy link
Owner

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.

@KevinDockx KevinDockx merged commit 203ee9a into KevinDockx:master Jan 14, 2024
@KevinDockx
Copy link
Owner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants