diff options
author | Teddy Wing | 2017-11-17 00:54:27 +0100 |
---|---|---|
committer | Teddy Wing | 2017-11-17 00:54:27 +0100 |
commit | 205fc3b71bd44067685c8517e7d126e3574827e1 (patch) | |
tree | 3deaeaa9ac1e5b23488b7f0b810ea3b88d3f04ca /src/main.rs | |
parent | cef74cbc8ccfac2b371db2cc9e99dda3c1fce166 (diff) | |
download | kipper-205fc3b71bd44067685c8517e7d126e3574827e1.tar.bz2 |
CommitRef::new(): Take a `JsonValue` instead of an `&str`
We expect to have pre-parsed the JSON as this function will get called
after `pull_request_opened_or_synchronized()`. To avoid doing the same
JSON parsing work twice, take a `JsonValue` argument in both functions.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 9ac9570..3bb2dbb 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,6 +16,7 @@ // along with Kipper. If not, see <http://www.gnu.org/licenses/>. extern crate getopts; +extern crate json; #[macro_use] extern crate log; extern crate stderrlog; @@ -129,7 +130,16 @@ fn main() { let mut body = String::new(); try_or_400!(data.read_to_string(&mut body)); - let commit_ref = match CommitRef::new(body.as_ref()) { + let json = match json::parse(body.as_ref()) { + Ok(j) => j, + Err(e) => { + error!("{}", e.to_string()); + + return internal_server_error() + }, + }; + + let commit_ref = match CommitRef::new(json) { Ok(cr) => cr, Err(e) => { error!("{}", e.to_string()); |