-
Notifications
You must be signed in to change notification settings - Fork 247
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
Improve support for typed HTTP headers #1829
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
analogrelay
commented
Sep 27, 2024
analogrelay
requested review from
Pilchie,
kirankumarkolli,
tvaron3,
FabianMeiswinkel,
kundadebdatta,
heaths,
RickWinter,
JeffreyRichter and
ronniegeraghty
as code owners
September 27, 2024 16:58
Pilchie
approved these changes
Sep 27, 2024
heaths
approved these changes
Sep 27, 2024
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this! I see nothing blocking, but had a few suggestions.
Co-authored-by: Kevin Pilch <kevinpi@microsoft.com>
analogrelay
force-pushed
the
ashleyst/asheaders-fromheaders
branch
from
September 30, 2024 20:28
d476911
to
39713d8
Compare
heaths
approved these changes
Sep 30, 2024
heaths
approved these changes
Oct 2, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #1826
This has two changes to improve support for typed HTTP headers:
AsHeaders
trait, used to convert a type into a set of HTTP headers, is now fallible. Types which can be infallibly converted to headers should set their error type tostd::convert::Infallible
(which will eventually be an alias for thenever
type!
).FromHeaders
trait, which allows for reading a type out of a set of HTTP headers. It's fallible and allows for returningNone
if the headers are simply not present. There are now two more methods onHeaders
:get
andget_optional
which allow for reading a required or optional value out of the headers.I've put a few notes inline that I wanted to specifically call attention to. I also updated
Range
(the only "built-in" type that implementsAsHeaders
) and switched Cosmos'PartitionKey
to implementAsHeaders
now that there's a way to return an error.