Skip to content

Controller 메서드 인자 매핑#59

Open
Aimbe wants to merge 14 commits intonext-step:aimbefrom
Aimbe:step4
Open

Controller 메서드 인자 매핑#59
Aimbe wants to merge 14 commits intonext-step:aimbefrom
Aimbe:step4

Conversation

@Aimbe
Copy link
Copy Markdown

@Aimbe Aimbe commented Aug 14, 2024

안녕하세요 동철님!
마지막 4단계 구현했습니다.항상 피드백 감사합니다!

Copy link
Copy Markdown

@sah3122 sah3122 left a comment

Choose a reason for hiding this comment

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

Controller 인자 매핑 구현 잘해주셨네요 👍
몇가지 고민거리를 남겨두었는데 확인 부탁드립니다 🙏

import jakarta.servlet.http.HttpServletResponse;
import java.lang.reflect.Parameter;

public interface ArgumentResolver {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Argument Resolver 인터페이스 정의 👍

import java.util.List;


public class MethodArgumentResolvers {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ArgumentResolver 일급 컬렉션 정의 👍

public class PathVariableResolver implements ArgumentResolver {
private final String urlPattern;

public PathVariableResolver(String urlPattern) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

urlPattern 을 상태 값으로 가지고 있는다면 해당 PathVariableResolver 는 특정 UrlPattern만을 지원할수 있는 Resolver로 역찰이 제한되게 될것 같습니다.
특정 패턴에 제한하지 않고 stateless한 클래스로 정의하여 한번 생성으로 재활용할수 있도록 변경해보는건 어떨까요 ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

넵 ArgumentResolver에서 Method 파라미터를 추가하여 구현하는것으로 변경했습니다!

Comment on lines +27 to +30
new HttpServletRequestResolver(),
new HttpServletResponseResolver(),
new PathVariableResolver(urlPattern),
new RequestParamResolver()
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

create 함수가 호출될때 마다 매번 생성하도록 정의해주셨는데, 재활용 할수 있는 구조로 변경해보는건 어떨까요 ?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

말씀하신 내용 반영해서 commit 했습니다!

public class TypeCheckUtil {

@SuppressWarnings("unchecked")
public static <T> T convertStringToTargetType(String value, Class<?> targetType) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

지원하는 원시 타입 정의 👍
개인적으로 조건문을 나열하기 보단 Enum 형태로 관리할수 있을듯 한데 도전해보세요 👍

public Object resolve(HttpServletRequest request, HttpServletResponse response, Parameter parameter) {
return request;
}
} No newline at end of file
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

사소하지만 파일의 마지막은 new line으로 끝나는것을 권장드립니다. 😄

@Aimbe
Copy link
Copy Markdown
Author

Aimbe commented Aug 20, 2024

피드백 내용 반영했습니다!

@Aimbe Aimbe requested a review from sah3122 August 20, 2024 15:49
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