Skip to content

Commit

Permalink
[#207] 불필요한 let절 제거
Browse files Browse the repository at this point in the history
  • Loading branch information
myyrakle committed Dec 29, 2024
1 parent 6461706 commit 340ad0d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 31 deletions.
14 changes: 4 additions & 10 deletions rupring/src/core/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,10 @@ pub async fn run_server(

let result = handle.await;

let response = match result {
match result {
Ok(response) => response,
Err(error) => default_join_error_handler(error),
};

response
}
}
}
});
Expand Down Expand Up @@ -372,9 +370,7 @@ pub async fn handle_event_on_aws_lambda(
let response_body = match response.body_mut().collect().await {
Ok(body) => {
let body = body.to_bytes();
let body = String::from_utf8(body.to_vec()).unwrap_or("".to_string());

body
String::from_utf8(body.to_vec()).unwrap_or("".to_string())
}
Err(error) => {
return Err(anyhow::Error::from(error));
Expand Down Expand Up @@ -515,9 +511,7 @@ where
let request_body = match request.collect().await {
Ok(body) => {
let body = body.to_bytes();
let body = String::from_utf8(body.to_vec()).unwrap_or("".to_string());

body
String::from_utf8(body.to_vec()).unwrap_or("".to_string())
}
Err(_) => {
return Ok::<Response<Full<Bytes>>, Infallible>(Response::new(Full::new(Bytes::from(
Expand Down
12 changes: 4 additions & 8 deletions rupring/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -489,11 +489,9 @@ impl<T: IModule + Clone + Copy + Sync + Send + 'static> RupringFactory<T> {

let runtime = runtime_builder.build()?;

let result = runtime.block_on(async {
runtime.block_on(async {
core::run_server(self.application_properties, self.root_module).await
});

result
})
}

#[cfg(feature = "aws-lambda")]
Expand All @@ -510,11 +508,9 @@ impl<T: IModule + Clone + Copy + Sync + Send + 'static> RupringFactory<T> {

let runtime = runtime_builder.build()?;

let result = runtime.block_on(async {
runtime.block_on(async {
core::run_server_on_aws_lambda(self.application_properties, self.root_module).await
});

result
})
}
}

Expand Down
4 changes: 1 addition & 3 deletions rupring/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,6 @@ impl From<Response> for hyper::Response<Full<Bytes>> {
}
}

let response = builder.body(Full::new(Bytes::from(response.body))).unwrap();

response
builder.body(Full::new(Bytes::from(response.body))).unwrap()
}
}
10 changes: 3 additions & 7 deletions rupring/src/swagger/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,9 +184,7 @@ impl<T: ToSwaggerDefinitionNode> ToSwaggerDefinitionNode for Vec<T> {

impl<T: ToSwaggerDefinitionNode> ToSwaggerDefinitionNode for Option<T> {
fn to_swagger_definition(context: &mut SwaggerDefinitionContext) -> SwaggerDefinitionNode {
let item = T::to_swagger_definition(context);

item
T::to_swagger_definition(context)
}
}
pub struct SwaggerRequestBody {
Expand All @@ -209,15 +207,13 @@ pub fn generate_swagger_request_info<T: ToSwaggerDefinitionNode>() -> Option<Swa

let mut swagger_request_body =
if let crate::swagger::macros::SwaggerDefinitionNode::Object(def) = root_definition {
let swagger_request_body = SwaggerRequestBody {
SwaggerRequestBody {
definition_name: root_definition_name,
definition_value: def.clone(),
dependencies: vec![],
path_parameters: def.path_parameters.clone(),
query_parameters: def.query_parameters.clone(),
};

swagger_request_body
}
} else {
return None;
};
Expand Down
4 changes: 1 addition & 3 deletions rupring/src/utils/hyper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ pub async fn send_http_request(
let response_body = match response.body_mut().collect().await {
Ok(body) => {
let body = body.to_bytes();
let body = String::from_utf8(body.to_vec()).unwrap_or("".to_string());

body
String::from_utf8(body.to_vec()).unwrap_or("".to_string())
}
Err(err) => {
return Err(anyhow::anyhow!("Failed to read response body: {:?}", err));
Expand Down

0 comments on commit 340ad0d

Please sign in to comment.