mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-18 05:41:50 +01:00
conditional response build
This commit is contained in:
parent
ce34eab832
commit
a1b7d5995e
@ -350,6 +350,15 @@ impl HttpResponseBuilder {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn if_true<F>(&mut self, value: bool, f: F) -> &mut Self
|
||||||
|
where F: Fn(&mut HttpResponseBuilder) + 'static
|
||||||
|
{
|
||||||
|
if value {
|
||||||
|
f(self);
|
||||||
|
}
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Set a body
|
/// Set a body
|
||||||
pub fn body<B: Into<Body>>(&mut self, body: B) -> Result<HttpResponse, HttpError> {
|
pub fn body<B: Into<Body>>(&mut self, body: B) -> Result<HttpResponse, HttpError> {
|
||||||
let mut parts = self.parts.take().expect("cannot reuse response builder");
|
let mut parts = self.parts.take().expect("cannot reuse response builder");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user