mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 09:12:57 +01:00
conditional response build
This commit is contained in:
parent
ce34eab832
commit
a1b7d5995e
@ -350,6 +350,15 @@ impl HttpResponseBuilder {
|
||||
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
|
||||
pub fn body<B: Into<Body>>(&mut self, body: B) -> Result<HttpResponse, HttpError> {
|
||||
let mut parts = self.parts.take().expect("cannot reuse response builder");
|
||||
|
Loading…
Reference in New Issue
Block a user