Skip to content

Conversation

@tkdgur0906
Copy link
Member

안녕하세요 잉크~
3단계 미션 진행 후 제출합니다!
전반적으로 리팩토링만 진행했습니다!

Copy link

@yechop yechop left a comment

Choose a reason for hiding this comment

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

3단계 리팩토링 잘 해주셨습니다 👍
몇 가지 코멘트 남겼습니다


public static HttpRequest from(InputStream inputStream) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String startLine = bufferedReader.readLine();
Copy link

Choose a reason for hiding this comment

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

RequestLine 을 분리하면 어떨까요 (lms 3단계 - 힌트 1 참고)

Copy link
Member Author

Choose a reason for hiding this comment

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

저런 힌트가 있었군요! HttpRequestLine 클래스를 생성해서 역할을 분리했습니다!

HttpMethod method = HttpMethod.from(parsedStartLine[0]);
String path = parsedStartLine[1];
String version = parsedStartLine[2];

Copy link

Choose a reason for hiding this comment

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

49~56번줄 while문 리팩토링 해주시면 좋을것 같아요.
지금은 while문의 조건이 true나 다름없습니다!

Copy link
Member Author

Choose a reason for hiding this comment

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

현재 while 방식으로는 조건문이 의미가 없고 무조건 if에서 처리되겠네요!
while문의 탈출 조건을 변경하였습니다!

public byte[] toHttpResponseBody() throws URISyntaxException, IOException {
URL url = getClass().getClassLoader().getResource(loadResourceName(path));
if (url == null) {
throw new IllegalArgumentException("존재하지 않는 리소스 입니다." + path);
Copy link

Choose a reason for hiding this comment

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

404도 고려해주세요

Copy link
Member Author

Choose a reason for hiding this comment

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

예외 종류별로 반환코드를 설정하면 좋을 것 같습니다!
다만 다른 기능의 우선순위가 높을 것 같아 추후 고려해보겠습니다!

} catch (IOException | UncheckedServletException e) {
log.error(e.getMessage(), e);
} catch (URISyntaxException e) {
} catch (Exception e) {
Copy link

Choose a reason for hiding this comment

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

알 수 없는 예외가 발생했을 때 어떤 응답을 주는게 좋을까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

알 수 없는 예외가 발생했을 때 500 에러를 반환하는 방어 로직을 작성해야 할 거 같습니다!
이 기능도 위와 동일하게 추후 고려해보겠습니다~

@yechop yechop merged commit 9fa3dd7 into woowacourse:tkdgur0906 Sep 13, 2024
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