Skip to content

Add accessors to TypedHeaderRejection fields - #317

Merged
davidpdrsn merged 4 commits into
tokio-rs:mainfrom
AlisCode:chore/change-field-visibility-in-typed-header-rejection
Sep 12, 2021
Merged

Add accessors to TypedHeaderRejection fields#317
davidpdrsn merged 4 commits into
tokio-rs:mainfrom
AlisCode:chore/change-field-visibility-in-typed-header-rejection

Conversation

@AlisCode

Copy link
Copy Markdown
Contributor

Motivation

Fixes #316.

Allows to implement a custom extractor that can behave depending on the header rejection's details (name and reason).
More details in the original issue.

Solution

  • Changes the field visibility from private to public.
  • Adds relevant documentation.
  • Exposes the inner Reason type publicly, because this doesn't compile otherwise.

@3olkin 3olkin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reason type should be exportable for having possibility to handle different reasons manually.
So those changes are not enough because typed_header module is private and all rejections is public from axum::extract::rejection.
IMHO simply reimport Reason type in rejection mode will be at least strange. So probably better way is making public only header name.

Comment thread src/extract/typed_header.rs
Comment thread src/extract/typed_header.rs Outdated

@davidpdrsn davidpdrsn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great! Thanks 😊 Wanna put a line in the changelog as well?

@davidpdrsn davidpdrsn changed the title Change fields visibility in TypedHeaderRejection from private to public (#316) Add accessors to TypedHeaderRejection fields Sep 12, 2021
@davidpdrsn davidpdrsn changed the title Add accessors to TypedHeaderRejection fields Add accessors to TypedHeaderRejection fields Sep 12, 2021
@AlisCode

Copy link
Copy Markdown
Contributor Author

Added the changelog entry as well

@davidpdrsn
davidpdrsn enabled auto-merge (squash) September 12, 2021 16:00
@davidpdrsn
davidpdrsn merged commit 0c18caa into tokio-rs:main Sep 12, 2021
davidpdrsn added a commit that referenced this pull request Sep 18, 2021
- Add accessors for `TypedHeaderRejection` fields ([#317])
- Improve docs for extractors ([#327])

[#317]: #317
[#327]: #327
@davidpdrsn davidpdrsn mentioned this pull request Sep 18, 2021
davidpdrsn added a commit that referenced this pull request Sep 18, 2021
- Add accessors for `TypedHeaderRejection` fields ([#317])
- Improve docs for extractors ([#327])

[#317]: #317
[#327]: #327
saad-aistack added a commit to saad-aistack/rust-high-perf-api that referenced this pull request Mar 26, 2026
- Add accessors for `TypedHeaderRejection` fields ([#317])
- Improve docs for extractors ([#327])

[#317]: tokio-rs/axum#317
[#327]: tokio-rs/axum#327
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.

Change fields visibility in TypedHeaderRejection from private to public

3 participants