Skip to content
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

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

buzz0331
Copy link

@buzz0331 buzz0331 commented Oct 4, 2024

No description provided.

Copy link

@JangIkhwan JangIkhwan left a comment

Choose a reason for hiding this comment

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

정말 고생했어요. 어려운 미션일텐데 리팩토링까지 잘 해주신 것 같아요!!! 👍

Comment on lines +39 to +43
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());
}

Choose a reason for hiding this comment

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

로그인 했는지 확인하는 것은 컨트롤러에서 체크하는 것이 좋을 것 같습니다. httpResponseHeader 객체는 값을 쓰는 역할만 하고, 값을 써야하는지 판단하는 건 컨트롤러에서 맡는 거죠

Comment on lines +44 to +48
public void setCss(String css) throws IOException {
body = Files.readAllBytes(Paths.get(ROOT.getUrl() + css));
response200(body.length, CSS);
responseBody();
}

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를 처리할 수 있겠죠?

Comment on lines +29 to +32
private static User findUser(Map<String, String> loginInfo) {
MemoryUserRepository memoryUserRepository = MemoryUserRepository.getInstance();
return memoryUserRepository.findUserById(loginInfo.get(USER_ID.getKey()));
}

Choose a reason for hiding this comment

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

repository 객체를 생성자 주입으로 받아서 사용해보는 건 어떨까요?

Comment on lines +11 to +12
private final int requestContentLength;
private final boolean LoginStatus;

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());

Choose a reason for hiding this comment

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

만약에 css파일의 이름을 바꾸면 어떻게 될까요?

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