mirror of
https://github.com/tokio-rs/axum.git
synced 2025-04-26 13:56:22 +02:00
Make status
a const function in rejection handling (#3168)
Signed-off-by: Awiteb <a@4rs.nl>
This commit is contained in:
parent
28c6be74ae
commit
e09cc59365
5 changed files with 17 additions and 5 deletions
|
@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
# Unreleased
|
||||
|
||||
- **change:** Make the `status` function for rejections generated by the
|
||||
`__define_rejection` and `__composite_rejection` macros a `const` function
|
||||
([#3168])
|
||||
|
||||
[#3168]: https://github.com/tokio-rs/axum/pull/3168
|
||||
|
||||
# 0.5.0
|
||||
|
||||
## since rc.1
|
||||
|
|
|
@ -54,7 +54,7 @@ macro_rules! __define_rejection {
|
|||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> http::StatusCode {
|
||||
pub const fn status(&self) -> http::StatusCode {
|
||||
http::StatusCode::$status
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ macro_rules! __define_rejection {
|
|||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> http::StatusCode {
|
||||
pub const fn status(&self) -> http::StatusCode {
|
||||
http::StatusCode::$status
|
||||
}
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ macro_rules! __composite_rejection {
|
|||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> http::StatusCode {
|
||||
pub const fn status(&self) -> http::StatusCode {
|
||||
match self {
|
||||
$(
|
||||
Self::$variant(inner) => inner.status(),
|
||||
|
|
|
@ -10,8 +10,11 @@ and this project adheres to [Semantic Versioning].
|
|||
- **breaking:** Remove unused `async-stream` feature, which was accidentally
|
||||
introduced as an implicit feature through an optional dependency which was no
|
||||
longer being used ([#3145])
|
||||
- **change:** Make the `status` function of rejections a `const` function, such
|
||||
as `FormRejection`, `QueryRejection` and `MultipartRejection` ([#3168])
|
||||
|
||||
[#3145]: https://github.com/tokio-rs/axum/pull/3145
|
||||
[#3168]: https://github.com/tokio-rs/axum/pull/3168
|
||||
|
||||
# 0.10.0
|
||||
|
||||
|
|
|
@ -9,9 +9,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
|
||||
- **added:** Implement `OptionalFromRequest` for `Json` ([#3142])
|
||||
- **added:** Implement `OptionalFromRequest` for `Extension` ([#3157])
|
||||
- **change:** Make the `status` function of rejections a `const` function, such
|
||||
as `JsonRejection`, `QueryRejection` and `PathRejection` ([#3168])
|
||||
|
||||
[#3142]: https://github.com/tokio-rs/axum/pull/3142
|
||||
[#3157]: https://github.com/tokio-rs/axum/pull/3157
|
||||
[#3168]: https://github.com/tokio-rs/axum/pull/3168
|
||||
|
||||
# 0.8.0
|
||||
|
||||
|
|
|
@ -429,7 +429,7 @@ impl FailedToDeserializePathParams {
|
|||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> StatusCode {
|
||||
pub const fn status(&self) -> StatusCode {
|
||||
match self.0.kind {
|
||||
ErrorKind::Message(_)
|
||||
| ErrorKind::DeserializeError { .. }
|
||||
|
@ -563,7 +563,7 @@ impl InvalidUtf8InPathParam {
|
|||
}
|
||||
|
||||
/// Get the status code used for this rejection.
|
||||
pub fn status(&self) -> StatusCode {
|
||||
pub const fn status(&self) -> StatusCode {
|
||||
StatusCode::BAD_REQUEST
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue