macro_rules! try_or_400 {
($result:expr) => { ... };
}
Expand description
This macro assumes that the current function returns a Response
and takes a Result
.
If the expression you pass to the macro is an error, then a 400 response is returned.
ยงExample
use rouille::Request;
use rouille::Response;
fn handle_something(request: &Request) -> Response {
let data = try_or_400!(post_input!(request, {
field1: u32,
field2: String,
}));
Response::text("hello")
}