Refactor Responder implementation for RumaResponse
parent
23f81bfaf7
commit
7067d7acae
|
@ -314,17 +314,18 @@ where
|
|||
'o: 'r,
|
||||
{
|
||||
fn respond_to(self, _: &'r Request<'_>) -> response::Result<'o> {
|
||||
let http_response: Result<http::Response<_>, _> = self.0.try_into_http_response();
|
||||
match http_response {
|
||||
Ok(http_response) => {
|
||||
let http_response = self
|
||||
.0
|
||||
.try_into_http_response()
|
||||
.map_err(|_| Status::InternalServerError)?;
|
||||
|
||||
let mut response = rocket::response::Response::build();
|
||||
|
||||
let status = http_response.status();
|
||||
response.raw_status(status.into(), "");
|
||||
|
||||
for header in http_response.headers() {
|
||||
response
|
||||
.raw_header(header.0.to_string(), header.1.to_str().unwrap().to_owned());
|
||||
response.raw_header(header.0.to_string(), header.1.to_str().unwrap().to_owned());
|
||||
}
|
||||
|
||||
let http_body = http_response.into_body();
|
||||
|
@ -343,7 +344,4 @@ where
|
|||
response.raw_header("Access-Control-Max-Age", "86400");
|
||||
response.ok()
|
||||
}
|
||||
Err(_) => Err(Status::InternalServerError),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue