1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-02 05:15:41 +02:00

add cors preflight request support

This commit is contained in:
Nikolay Kim
2018-01-09 23:55:42 -08:00
parent ce78f17a79
commit d7f59ce481
2 changed files with 137 additions and 5 deletions

View File

@@ -404,6 +404,16 @@ impl HttpResponseBuilder {
self
}
/// This method calls provided closure with builder reference if value is Some.
pub fn if_some<T, F>(&mut self, value: Option<&T>, f: F) -> &mut Self
where F: Fn(&T, &mut HttpResponseBuilder) + 'static
{
if let Some(val) = value {
f(val, self);
}
self
}
/// Set a body and generate `HttpResponse`.
///
/// `HttpResponseBuilder` can not be used after this call.