Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[톰캣 구현하기 3, 4단계] 토리(천은정) 미션 제출합니다. #491

Merged
merged 6 commits into from
Sep 14, 2023

Conversation

ezzanzzan
Copy link
Member

@ezzanzzan ezzanzzan commented Sep 11, 2023

안녕하세요 아벨 !! 오랜만이에요 ˙ᵕ˙
겨우겨우 제한 시간 전에 리뷰 요청을 드리네요.. 🥲
이번 미션을 진행하며 구조를 갈아엎는 과정에서 오류가 계속 발생해서 커밋을 잘 분리하지 못했어요..
열심히 구조를 나누고 리팩터링을 진행했는데 여러번 다시 하느라 시간이 오래걸렸네요 🥲
리뷰 잘 부탁드립니다 ! 좋은 하루 되세요 🌈

- HttpRequest 클래스 구조 분리 및 역할 세분화
    - HttpRequestLine
        - HttpMethod
        - HttpPath
        - HttpProtocol
    - HttpRequestHeaders
    - HttpRequestBody
- HttpProtocol enum 클래스 추가
- HttpResponse 구조 변경
- HttpRequest 객체의 요청을 처리할 FrontController 추가
- Http11Processor 내부 HttpRequest path로 인한 분기 로직 책임 분리
@ezzanzzan ezzanzzan self-assigned this Sep 11, 2023
@sonarcloud
Copy link

sonarcloud bot commented Sep 11, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 5 Code Smells

0.0% 0.0% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.20.1) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

Copy link

@tjdtls690 tjdtls690 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

토리! 리뷰가 많이 늦어져서 정말 죄송합니다.

각 클래스의 역할에 맞춰서 코드를 분리하고 아키텍처를 설계한 것을 보고 정말 많이 배웠습니다. 제가 보기에 피드백 할 부분이 별로 없었던 것 같아요.

몇 가지 질문과 리뷰 남겼으니 확인해주세요! 정말 수고 많으셨습니다.

this.headers = headers;
this.body = body;
}

public static HttpRequest from(final BufferedReader bufferedReader) throws IOException {
final List<String> requestHeader = extractRequestHeader(bufferedReader);
final HttpRequestStartLine startLine = HttpRequestStartLine.from(requestHeader.get(0));
final HttpRequestLine startLine = HttpRequestLine.from(requestHeader.get(0));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

첫번째 라인은 보통 Request Line 이라 하더라구요. 그래서 Header에서 Request Line을 꺼내는 모양이 조금 어색해 보였어요.

final String requestLine = bufferedReader.readLine();
final HttpRequestLine startLine = HttpRequestLine.from(requestLine);

이런 식으로 첫 줄을 먼저 꺼내서 RequestLine을 만들어 주는 것은 어떨까요? 그 다음에 RequestHeaders를 만드는 식이 될것 같아요.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

저는 extractRequestHeader에서 bufferrReader를 통해 한 번에 리스트를 통해 읽어서 requestLine과 header로 잘라서 보내주었습니다 bufferReader를 여기저기 퍼트려두기 싫었어요 .. ..
일단 startLine이라고 적혀있던 네이밍을 requestLine으로 변경하였습니다 ! (놓치고 변경하지 못한 부분이네요 ..)
리뷰를 보면서 코드를 보니 아벨이 추천해주신 방식이 더 가독성이 좋아보여서 변경해버렸습니다 ˙ᵕ˙ 👍


private final ServerSocket serverSocket;
private final ExecutorService executorService;
private final FrontController frontController;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FrontController를 싱글톤 형식으로 관리하기 위한 방법으론 Http11Processor에서 private static final로 가지는 방법도 있었을 것 같은데, Connector의 인스턴스 변수로 가지는 방법을 택한 이유가 무엇인지 궁금합니다 :)

Comment on lines +28 to +33
protected HttpCookie makeHttpCookie(final HttpRequest httpRequest) {
if (httpRequest.hasCookie()) {
return HttpCookie.from(httpRequest.getCookie());
}
return HttpCookie.empty();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makeHttpCookie메서드는 현재도 그렇고 앞으로도 로그인과 관련된 로직이 존재하는 LoginController에서만 사용이 될 것 같은데, 이 메서드를 LoginController로 옮기는 것은 어떨까요? 코드를 파악하기에도 좀 더 수월해질 것 같아요!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

여러곳에서 사용될 수 있을 것 같아 AbstractController에 두었는데 로그인이 성공했을 때만 사용되고 있네요 !
LoignController로 옮긴 뒤 접근제어자도 private로 변경하였습니다 ˙ᵕ˙

import org.apache.coyote.http11.request.HttpRequest;
import org.apache.coyote.http11.response.HttpResponse;

public class ResourceController extends AbstractController {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResourceController 컨트롤러를 LoginController, HomeController, RegisterController 이 컨트롤러들과 따로 위치시킨 이유가 궁금합니다 :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LoginController, HomeController, RegisterController 는 서비스 로직이라고 생각했고, ResourceController는 톰캣에서 맵핑할 컨트롤러가 존재하지 않을 때 리소스를 출력해주는 역할을 한다고 생각해서 따로 위치시켜두었습니다 !!
아벨의 의견도 궁금합니다 !

@tjdtls690 tjdtls690 merged commit 364e4e0 into woowacourse:ezzanzzan Sep 14, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants