We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
CONTENT_TYPE
1 parent 6b4017c commit 9a0e44dCopy full SHA for 9a0e44d
1 file changed
ohkami/src/typed/status.rs
@@ -43,12 +43,15 @@ macro_rules! generate_statuses_as_types_containing_value {
43
impl<B: IntoBody> IntoResponse for $status<B> {
44
#[inline]
45
fn into_response(self) -> Response {
46
- let body = match self.body.into_body() {
47
- Ok(body) => body,
48
- Err(e) => {
+ let body = match (const {B::CONTENT_TYPE}, self.body.into_body()) {
+ ("", _) => {// will be removed by optimization if it's not
+ return Response::OK();
49
+ }
50
+ (_, Err(e)) => {
51
crate::ERROR!("<{} as IntoBody>::into_body() failed: {e}", std::any::type_name::<B>());
52
return Response::InternalServerError();
53
}
54
+ (_, Ok(body)) => body,
55
};
56
57
let mut headers = self.headers;
0 commit comments