Clean code, remove unnecessary variable req_res

This commit is contained in:
Jie Yang 2017-08-21 21:07:06 +08:00
parent 944736208e
commit 6f2302c3c7
1 changed files with 11 additions and 10 deletions

View File

@ -50,12 +50,13 @@ impl hyper::Handler for Rocket {
let (h_addr, h_method, h_headers, h_uri, _, h_body) = hyp_req.deconstruct(); let (h_addr, h_method, h_headers, h_uri, _, h_body) = hyp_req.deconstruct();
// Convert the Hyper request into a Rocket request. // Convert the Hyper request into a Rocket request.
let req_res = Request::from_hyp(self, h_method, h_headers, h_uri, h_addr); let mut req =
let mut req = match req_res { match Request::from_hyp(self, h_method, h_headers, h_uri, h_addr) {
Ok(req) => req, Ok(req) => req,
Err(e) => { Err(e) => {
error!("Bad incoming request: {}", e); error!("Bad incoming request: {}", e);
let dummy = Request::new(self, Method::Get, URI::new("<unknown>")); let dummy =
Request::new(self, Method::Get, URI::new("<unknown>"));
let r = self.handle_error(Status::InternalServerError, &dummy); let r = self.handle_error(Status::InternalServerError, &dummy);
return self.issue_response(r, res); return self.issue_response(r, res);
} }