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

[MVC 구현하기 - 1단계] 레오(차영호) 미션 제출합니다. #387

Merged
merged 5 commits into from
Sep 14, 2023

Conversation

youngh0
Copy link

@youngh0 youngh0 commented Sep 13, 2023

안녕하세요 오잉! 레오입니다
미션에서 만나니 반갑네요😎

1단계 로직 흐름에 대해 간단하게 말씀 드리자면 아래와 같습니다.

  1. @controller 붙은 클래스를 찾는다.
  2. 찾은 클래스 중 @RequestMapping 이 붙은 메서드를 찾는다.
  3. 찾은 메서드의 @RequestMapping 정보를 이용해 HandlerKey, HandlerExecution 을 만든다.

리뷰 하시다가 궁금한 점 있으면 언제든 물어봐주십쇼~ MVC 미션 잘 부탁드려요 ㅎㅎ

Copy link

@hanueleee hanueleee left a comment

Choose a reason for hiding this comment

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

안녕하세요 레오!!
미션에서 만나니 반갑네요 👻

코드가 깔끔해서 리뷰하기 좋았습니다 굿굿
특히 getConstructor 부분 예외처리 인상깊었습니다!

소소하게 궁금한 부분들에 대해 질문 남겨놨어요~~
1단계 요구사항은 모두 충족하신 것 같아서 바로 머지하겠습니다.

다음 단계도 기대하겠습니당 화이팅!!

GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE
GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;

public static RequestMethod from(String methodName) {

Choose a reason for hiding this comment

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

valueOf 대신 정팩메를 만든 이유가 궁금합니다~~


import static org.assertj.core.api.Assertions.assertThat;

class RequestMethodTest {

Choose a reason for hiding this comment

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

꼼꼼한 테스트 굿

void 존재하지_않는_메서드면_예외() {
String invalidMethodName = "get??";

Assertions.assertThatThrownBy(() -> RequestMethod.from(invalidMethodName))

Choose a reason for hiding this comment

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

static import 처리해주면 좋을 것 같아용!

Comment on lines 13 to 21
private final Constructor<?> constructor;

public HandlerExecution(Method method, Constructor<?> constructor) {
this.method = method;
this.constructor = constructor;
}

public ModelAndView handle(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
return null;
return (ModelAndView) method.invoke(constructor.newInstance(), request, response);

Choose a reason for hiding this comment

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

constructor를 상태로 갖고 있고
handle 메소드 호출시마다 constructor로 새로 instance를 만드는 이유가 궁금합니다!

Comment on lines +49 to +56
private Constructor<?> getConstructor(Class<?> controller) {
try {
return controller.getConstructor();
} catch (NoSuchMethodException e) {
log.error("{} 의 기본 생성자가 존재하지 않습니다.", controller.getName());
throw new RuntimeException(String.format("%s 의 기본 생성자가 존재하지 않습니다.", controller.getName()));
}
}

Choose a reason for hiding this comment

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

예외처리 꼼꼼하네요 굿굿👍

@hanueleee hanueleee merged commit 3a3e4b0 into woowacourse:youngh0 Sep 14, 2023
1 check failed
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.

3 participants