[레베카] 3단계 - HTTP 웹 서버 리팩토링 미션 제출합니다.#179
Open
chws wants to merge 18 commits intowoowacourse:chwsfrom
Open
Conversation
- HttpSessionStorage.addSession에서 httpSession을 리턴하는 방식 수정 - HttpResponseHeaderParser에서 Set-Cookie에 Path 추가
- UserLogoutController 작성 - 추상 클래스 AuthController를 작성하여 세션을 가져오는 메소드 추가 - Set-Cookie 구현 방식 수정
jeonghoon1107
suggested changes
Oct 29, 2020
jeonghoon1107
left a comment
There was a problem hiding this comment.
안녕하세요 레베카!
구현 잘 해주셨네요.
간단한 피드백을 남겼으니 확인해주세요.
중복되는 내용은 별도로 남기지 않았어요!
| @Override | ||
| public HttpResponse get(HttpRequest httpRequest) { | ||
| try { | ||
| TemplateLoader loader = new ClassPathTemplateLoader(); |
There was a problem hiding this comment.
template 부분과 비즈니스로직을 분리해보면 어떨까요?
| public abstract class AuthController extends Controller { | ||
| protected HttpSession retrieveHttpSession(HttpRequest httpRequest) { | ||
| if (httpRequest.hasCookie("SESSIONID")) { | ||
| HttpSession httpSession = HttpSessionStorage.getSession(httpRequest.getSessionId()); |
There was a problem hiding this comment.
getSession을 했을 때 존재하지 않으면 내부에서 만들어주면 어떨까요?
HttpSessionStorage를 controller까지 오픈할 필요는 없을 것 같아요.
| boolean auth = userService.authenticateUser(httpRequest); | ||
| String header; | ||
| HttpSession httpSession; | ||
| Cookie cookie = new Cookie(); |
| public class UserLogoutController extends AuthController { | ||
| @Override | ||
| public HttpResponse get(HttpRequest httpRequest) { | ||
| String header; |
| public class HttpSessionStorage { | ||
| private static Map<String, HttpSession> storage = new HashMap<>(); | ||
|
|
||
| public static HttpSession addSession(HttpSession httpSession) { |
|
|
||
| import static org.assertj.core.api.Assertions.assertThat; | ||
|
|
||
| class CookieTest { |
| } | ||
|
|
||
| public static String badRequest() { | ||
| return "HTTP/1.1 400 Bad Request \r\n" + |
There was a problem hiding this comment.
시스템 OS에 따라 개행이 달라질 수 있는데 System.lineSeparator()를 사용하면 어떨까요?
| public boolean authenticateUser(HttpRequest httpRequest) { | ||
| String userId = httpRequest.getBodyValue("userId"); | ||
| String password = httpRequest.getBodyValue("password"); | ||
| User userById = DataBase.findUserById(userId); |
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.
안녕하세요!
많은 지적 부탁드립니다:-)
감사합니다