mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
add IntoResponseFailed to existing fallible responses
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
use axum::{
|
||||
async_trait,
|
||||
extract::{rejection::BytesRejection, FromRequest, Request},
|
||||
response::{IntoResponse, Response},
|
||||
response::{IntoResponse, IntoResponseFailed, Response},
|
||||
};
|
||||
use bytes::{Bytes, BytesMut};
|
||||
use http::StatusCode;
|
||||
@@ -124,7 +124,12 @@ where
|
||||
let mut buf = BytesMut::with_capacity(128);
|
||||
match &self.0.encode(&mut buf) {
|
||||
Ok(()) => buf.into_response(),
|
||||
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response(),
|
||||
Err(err) => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
IntoResponseFailed,
|
||||
err.to_string(),
|
||||
)
|
||||
.into_response(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use std::sync::Arc;
|
||||
|
||||
use axum::{
|
||||
http::{header, HeaderValue, StatusCode},
|
||||
response::{IntoResponse, Response},
|
||||
response::{IntoResponse, IntoResponseFailed, Response},
|
||||
};
|
||||
use bytes::{BufMut, Bytes, BytesMut};
|
||||
use serde::Serialize;
|
||||
@@ -68,7 +68,12 @@ impl IntoResponse for ErasedJson {
|
||||
bytes,
|
||||
)
|
||||
.into_response(),
|
||||
Err(err) => (StatusCode::INTERNAL_SERVER_ERROR, err.to_string()).into_response(),
|
||||
Err(err) => (
|
||||
StatusCode::INTERNAL_SERVER_ERROR,
|
||||
IntoResponseFailed,
|
||||
err.to_string(),
|
||||
)
|
||||
.into_response(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user