macro_rules! result_to_response { ($handler: path) => { |req: Request| -> Response { let log = req .extensions() .get::() .expect("Our logger should be on req.") .clone(); let path = path_from_request(&req); let result = $handler(req); match result { Ok(response) => { info!(log, "Request successful: {:?}", path); response } Err(e) => { info!(log, "Request failure: {:?}", path); e.into() } } } }; }