Macro rouille::try_or_400
[−]
[src]
macro_rules! try_or_400 { ($result:expr) => { ... }; }
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 { #[derive(RustcDecodable)] struct FormData { field1: u32, field2: String, } let _data: FormData = try_or_400!(rouille::input::get_post_input(request)); Response::text("hello") }