Round 5#117
Open
APapeIsName wants to merge 13 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
설계는 아래와 같이 정했습니다.
@controller 를 추가하려면 어떻게 해야 할까?
기존의 ApplicationContext 에 추가 -> 이렇게 하면 뭐 추가할 때마다 코드가 계속해서 늘어나게 됨. 근데 Controller 자체는 사실 @component 로 써도 무방.
즉, ApplicationContext의 확장성을 보장하고, 추가할 때마다 따로 뭔가를 받으면 되게끔 설정하면 되지 않을까
-> @controller -> @component 로 받을 수 있게 처리해주는 게 필요함
@controller 를 달고 있는 애들은
기존 Controller 의 문제 = 인터페이스 기반은 직접 메소드 구현해서 switch case 매핑해서 연결,
어노테이션 기반은 주소받아서 따로 연결시켜줘야 하고 RequestMapping 으로 GET, POST 등 명시해줘야 함
해결 방법 = 이를 구현하도록 하는 곳(즉, GET, POST 연결하는 쪽)은 따로 하고,
인터페이스는 이걸 구현하기만 해도 되는 식으로 만들고
어노테이션은 명시된 걸 보고 알아서 진행되는 식
어차피 중요한 건 입력인 Request, 출력인 Response 만 제대로 돼 있으면 됨
HttpServletController = Request 오면 GET, POST 등 분기해주고(controller 인자로 넘겨줌) 다음으로 넘김 그리고 응답값을 Response 로 보내줌
@RequestMapping("/lectures") 을 클래스 위에 붙이면
그 Controller 아래 있는 모든 @RequestMapping에 url의 맨 앞으로 붙여지게 됨
만약에 메소드 위에 @RequestMapping() 이 붙을 때는 HttpRequestMethod 값이 필수 요소가 됨 없으면 메소드 없다고 쫓아내기
HttpServletContext 가 해야 할 일
이 Method + url 이 오면 -> controllerMap.find 가능하게 추가해줘야 함. 근데 value가 둘 이상이라면? -> 예외 발생
구현 도중 중단하여 우선 PR 먼저 올려둡니다.