-
Notifications
You must be signed in to change notification settings - Fork 23
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
3주차 미션 / 서버 3조 장현준 #10
base: main
Are you sure you want to change the base?
Conversation
1. 쿼리 파싱 함수 리팩토링 2. 로그인 함수 리팩토링
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.
정말 고생했어요. 어려운 미션일텐데 리팩토링까지 잘 해주신 것 같아요!!! 👍
public void setCookie(boolean isLogin) throws IOException { | ||
if(isLogin){ | ||
final String LOGIN_TRUE = "logined=true"; | ||
dos.write((SET_COOKIE.getHeader()+ COLON + LOGIN_TRUE + CRLF).getBytes()); | ||
} |
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.
로그인 했는지 확인하는 것은 컨트롤러에서 체크하는 것이 좋을 것 같습니다. httpResponseHeader 객체는 값을 쓰는 역할만 하고, 값을 써야하는지 판단하는 건 컨트롤러에서 맡는 거죠
public void setCss(String css) throws IOException { | ||
body = Files.readAllBytes(Paths.get(ROOT.getUrl() + css)); | ||
response200(body.length, CSS); | ||
responseBody(); | ||
} |
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.
forward() 기능과 큰 차이가 없는 것 같아요. forward()에서 확장자가 html인지 css인지 확인해서 알맞은 content-type이 응답메시지에 담기도록 수정해보면 어떨까요? 알맞은 컨트롤러가 없으면 forward()를 호출하니까 css를 처리할 수 있겠죠?
private static User findUser(Map<String, String> loginInfo) { | ||
MemoryUserRepository memoryUserRepository = MemoryUserRepository.getInstance(); | ||
return memoryUserRepository.findUserById(loginInfo.get(USER_ID.getKey())); | ||
} |
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.
repository 객체를 생성자 주입으로 받아서 사용해보는 건 어떨까요?
private final int requestContentLength; | ||
private final boolean LoginStatus; |
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.
헤더에는 여러 가지 정보가 들어가죠. 미션에서는 쿠키의 로그인 상태만 보려고 했지만, 좀 더 다양한 상황을 처리하려면 헤더의 모든 키와 값을 Map에 저장하는 것이 좋은 방법이 될 것 같아요.
controllers.put(URL.SIGNUP.getUrl(), new SignUpController()); | ||
controllers.put(URL.LOGIN.getUrl(), new LoginController()); | ||
controllers.put(URL.USER_LIST.getUrl(), new UserListController()); | ||
controllers.put(URL.CSS.getUrl(), new CssController()); |
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.
만약에 css파일의 이름을 바꾸면 어떻게 될까요?
No description provided.