-
Notifications
You must be signed in to change notification settings - Fork 302
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
Conversation
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static import 처리해주면 좋을 것 같아용!
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constructor를 상태로 갖고 있고
handle 메소드 호출시마다 constructor로 새로 instance를 만드는 이유가 궁금합니다!
private Constructor<?> getConstructor(Class<?> controller) { | ||
try { | ||
return controller.getConstructor(); | ||
} catch (NoSuchMethodException e) { | ||
log.error("{} 의 기본 생성자가 존재하지 않습니다.", controller.getName()); | ||
throw new RuntimeException(String.format("%s 의 기본 생성자가 존재하지 않습니다.", controller.getName())); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
예외처리 꼼꼼하네요 굿굿👍
안녕하세요 오잉! 레오입니다
미션에서 만나니 반갑네요😎
1단계 로직 흐름에 대해 간단하게 말씀 드리자면 아래와 같습니다.
리뷰 하시다가 궁금한 점 있으면 언제든 물어봐주십쇼~ MVC 미션 잘 부탁드려요 ㅎㅎ