macro_rules! assert_or_400 {
    ($cond:expr) => { ... };
}
Expand description

This macro assumes that the current function returns a Response. If the condition you pass to the macro is false, 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,
    }));

    assert_or_400!(data.field1 >= 2);
    Response::text("hello")
}