Add stuff method
@@ -287,7 +287,7 @@ impl Response {
self.status_error = Some(err);
}
- /// Render text as html content. It will set ```content-type``` to ```text/html; charset=utf-8```.
+ /// Render content.
#[inline]
pub fn render<P>(&mut self, piece: P)
where
@@ -296,6 +296,16 @@ impl Response {
piece.render(self)
}
+ /// Render content with status code.
+ #[inline]
+ pub fn stuff<P>(&mut self, code: StatusCode, piece: P)
+ where
+ P: Piece,
+ {
+ self.status_code = Some(code);
+ piece.render(self)
+ }
+
/// Write bytes data to body. If body is none, a new `Body` will created.
#[inline]
pub fn write_body(&mut self, data: &[u8]) -> crate::Result<()> {
