mirror of
https://github.com/tokio-rs/axum.git
synced 2025-10-03 15:55:01 +00:00
Add is_missing method to typed header rejection reason (#2503)
This commit is contained in:
parent
f7c4cd883a
commit
791d5038a9
@ -9,8 +9,10 @@ and this project adheres to [Semantic Versioning].
|
|||||||
|
|
||||||
- **added:** Implement `TypedPath` for `WithRejection<TypedPath, _>`
|
- **added:** Implement `TypedPath` for `WithRejection<TypedPath, _>`
|
||||||
- **fixed:** Documentation link to `serde::Deserialize` in `JsonDeserializer` extractor ([#2498])
|
- **fixed:** Documentation link to `serde::Deserialize` in `JsonDeserializer` extractor ([#2498])
|
||||||
|
- **added:** Add `is_missing` function for `TypedHeaderRejection` and `TypedHeaderRejectionReason` ([#2503])
|
||||||
|
|
||||||
[#2498]: https://github.com/tokio-rs/axum/pull/2498
|
[#2498]: https://github.com/tokio-rs/axum/pull/2498
|
||||||
|
[#2503]: https://github.com/tokio-rs/axum/pull/2503
|
||||||
|
|
||||||
# 0.9.1 (29. December, 2023)
|
# 0.9.1 (29. December, 2023)
|
||||||
|
|
||||||
|
@ -123,6 +123,14 @@ impl TypedHeaderRejection {
|
|||||||
pub fn reason(&self) -> &TypedHeaderRejectionReason {
|
pub fn reason(&self) -> &TypedHeaderRejectionReason {
|
||||||
&self.reason
|
&self.reason
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns `true` if the typed header rejection reason is [`Missing`].
|
||||||
|
///
|
||||||
|
/// [`Missing`]: TypedHeaderRejectionReason::Missing
|
||||||
|
#[must_use]
|
||||||
|
pub fn is_missing(&self) -> bool {
|
||||||
|
self.reason.is_missing()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Additional information regarding a [`TypedHeaderRejection`]
|
/// Additional information regarding a [`TypedHeaderRejection`]
|
||||||
@ -136,6 +144,16 @@ pub enum TypedHeaderRejectionReason {
|
|||||||
Error(headers::Error),
|
Error(headers::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TypedHeaderRejectionReason {
|
||||||
|
/// Returns `true` if the typed header rejection reason is [`Missing`].
|
||||||
|
///
|
||||||
|
/// [`Missing`]: TypedHeaderRejectionReason::Missing
|
||||||
|
#[must_use]
|
||||||
|
pub fn is_missing(&self) -> bool {
|
||||||
|
matches!(self, Self::Missing)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl IntoResponse for TypedHeaderRejection {
|
impl IntoResponse for TypedHeaderRejection {
|
||||||
fn into_response(self) -> Response {
|
fn into_response(self) -> Response {
|
||||||
(http::StatusCode::BAD_REQUEST, self.to_string()).into_response()
|
(http::StatusCode::BAD_REQUEST, self.to_string()).into_response()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user