-
Notifications
You must be signed in to change notification settings - Fork 90
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단계 - HTTP 웹 서버 리팩토링 미션 제출합니다. #179
base: chws
Are you sure you want to change the base?
Conversation
- HttpSessionStorage.addSession에서 httpSession을 리턴하는 방식 수정 - HttpResponseHeaderParser에서 Set-Cookie에 Path 추가
- UserLogoutController 작성 - 추상 클래스 AuthController를 작성하여 세션을 가져오는 메소드 추가 - Set-Cookie 구현 방식 수정
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.
안녕하세요 레베카!
구현 잘 해주셨네요.
간단한 피드백을 남겼으니 확인해주세요.
중복되는 내용은 별도로 남기지 않았어요!
@Override | ||
public HttpResponse get(HttpRequest httpRequest) { | ||
try { | ||
TemplateLoader loader = new ClassPathTemplateLoader(); |
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getSession을 했을 때 존재하지 않으면 내부에서 만들어주면 어떨까요?
HttpSessionStorage를 controller까지 오픈할 필요는 없을 것 같아요.
boolean auth = userService.authenticateUser(httpRequest); | ||
String header; | ||
HttpSession httpSession; | ||
Cookie cookie = new Cookie(); |
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.
cookie 객체 생성을 내부로 감추면 어떨까요?
public class UserLogoutController extends AuthController { | ||
@Override | ||
public HttpResponse get(HttpRequest httpRequest) { | ||
String header; |
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 class HttpSessionStorage { | ||
private static Map<String, HttpSession> storage = new HashMap<>(); | ||
|
||
public static HttpSession addSession(HttpSession httpSession) { |
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.
내부에서만 사용한다면 접근제어자를 수정하면 어떨까요?
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class CookieTest { |
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 static String badRequest() { | ||
return "HTTP/1.1 400 Bad Request \r\n" + |
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.
시스템 OS에 따라 개행이 달라질 수 있는데 System.lineSeparator()를 사용하면 어떨까요?
public boolean authenticateUser(HttpRequest httpRequest) { | ||
String userId = httpRequest.getBodyValue("userId"); | ||
String password = httpRequest.getBodyValue("password"); | ||
User userById = DataBase.findUserById(userId); |
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.
Optional을 반환해도 좋을 것 같네요
안녕하세요!
많은 지적 부탁드립니다:-)
감사합니다