diff --git a/axum-core/src/response/into_response_parts.rs b/axum-core/src/response/into_response_parts.rs index 5810bef7..e85855b1 100644 --- a/axum-core/src/response/into_response_parts.rs +++ b/axum-core/src/response/into_response_parts.rs @@ -80,6 +80,21 @@ pub trait IntoResponseParts { fn into_response_parts(self, res: ResponseParts) -> Result; } +impl IntoResponseParts for Option +where + T: IntoResponseParts, +{ + type Error = T::Error; + + fn into_response_parts(self, res: ResponseParts) -> Result { + if let Some(inner) = self { + inner.into_response_parts(res) + } else { + Ok(res) + } + } +} + /// Parts of a response. /// /// Used with [`IntoResponseParts`].