-
Notifications
You must be signed in to change notification settings - Fork 707
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
MediaTypeApiVersionReader to skip application/signed-exchange #887
Comments
This is an interesting case. I certainly haven't seen something else use a It's plausible to add support to
High request rates increase the usage of |
Thank you for your fast response. Yes, I both acknowledge the workaround and extensibility part, but I also like you to have the opportunity to consider having a MIME type filter - either inclusive or exclusive - I think this would help greatly in spreading the MediaType approach. That being said, I also reckon that you are a busy guy .. I will consider my options, and if I decide to add my own implementation, I can share it with you here; then you can consider if its viable to serve as inspiration to nudge your default implementation, or it should simply be an implementation I share in my extension library for your framework. Could also be a Pull Request if you are interested? |
I choose to opt-in for a generic and whitelist proposal which I have made part of my library. The MediaTypeApiVersionReader I implemented can be found here: https://github.com/gimlichael/Cuemon/blob/development/src/Cuemon.Extensions.Asp.Versioning/RestfulApiVersionParser.cs, and it is being initialized with there three media types: "application/json", "application/xml" and "application/vnd". This means that instead of looking through all media types, I decided to only look for the more common negotiation paths of an API. For me the result is satisfying, and I can keep my v for versioning without triggering the InvalidApiVersion application/signed-exchange media type . |
Interesting... I've been thinking about this some more. I see that you went with an inclusive selection model. I was thinking exclusive. Funny how something so seemingly innocuous can go sideways. I've tried to go enable Pay for Play. My general thought process is to add a I also noticed that you are using fuzzy inclusive matching a la
These nuances can run amuck pretty quickly. It can be hard to judge which scenarios are common enough to bake in versus leave to customization. It's going to require some more thinking, but you might be on to something that would address a couple of edge cases. |
Cool - glad if I at all have planted a seed 🌱 I agree to the application/vnd .. and this is also why I opt-in for StarsWith. I like how you are already engineering the idea; looking forward to your proposal 😉 |
I think I have a good baseline of what this would look like. I pushed the working branch. You can see the commit with all that support here. There is some serious sorcery🧙🏽♂️. The new
Your scenario: var builder = new MediaTypeApiVersionReaderBuilder()
var reader = builder
.Parameter( "v" )
.Include( "application/json" )
.Include( "application/xml" )
.Template( "application/vnd-v{ver}+json" )
.Template( "application/vnd-v{ver}+xml" )
.Build(); This provides a lot of flexibility. The more you add, the more evaluations there are per request, but that's kind of a given. This will consider:
All considerations are made because there could be multiple in a request. If multiple are allowed, you can disambiguate through the var builder = new MediaTypeApiVersionReaderBuilder()
var reader = builder
.Choose( versions => versions.Count == 0 ? versions : new[]{ versions[0] } )
.ChooseFirstOrDefault() // shortcut for the same thing
.Build(); Give it a peek and see what you think. I think this would cover your scenario and much more. |
Most impressive work - I am fan! Thank you for effort - what release are you planning this for? |
It will be in the next release. I thought it would just be Added a few minor changes:
|
Is there an existing issue for this?
Is your feature request related to a problem? Please describe the problem.
When I am doing a fast test of various APIs for GET operations, I like to use a browser.
It seems that Chromium (both Edge and Chrome) has introduced the in title referenced header: https://wicg.github.io/webpackage/draft-yasskin-http-origin-signed-responses.html#section-8.6
This "throws" a 400/InvalidApiVersion when encountered and my API is set to use v for version parameter name.
Describe the solution you'd like
If possible, tweak MediaTypeApiVersionReader to be aware of this IANA defined header (application/signed-exchange) and read pass it (eg. skip it).
Additional context
https://github.com/dotnet/aspnet-api-versioning/blob/main/src/Common/src/Common/MediaTypeApiVersionReader.cs
The text was updated successfully, but these errors were encountered: