From 7a4b816b6dc8c826db49bc5997709b8e7d1f6933 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Fri, 17 Nov 2017 00:20:47 +0100 Subject: main(): Move `body` var definition to where it's used Don't bother creating the variable if we don't receive any data. Instead, initialise the variable right where we need it. --- src/main.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index c7be3ee..9ac9570 100644 --- a/src/main.rs +++ b/src/main.rs @@ -122,12 +122,11 @@ fn main() { rouille::start_server(format!("127.0.0.1:{}", port), move |request| { router!(request, (POST) (/github/pull_request_event) => { - let mut body = String::new(); - match request.data() { None => rouille::Response::text("400 Bad Request") .with_status_code(400), Some(mut data) => { + let mut body = String::new(); try_or_400!(data.read_to_string(&mut body)); let commit_ref = match CommitRef::new(body.as_ref()) { -- cgit v1.2.3