-
Notifications
You must be signed in to change notification settings - Fork 24
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조 이윤희 #19
base: main
Are you sure you want to change the base?
Conversation
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 HomeController implements Controller { | ||
@Override | ||
public void execute(HttpRequest request, HttpResponse response) throws Exception { | ||
response.forward("/index.html"); |
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.
url을 enum으로 관리하니까 enum을 사용하는 게 어떨까요?
import static enumClass.UserQueryKey.*; | ||
|
||
public class LoginController implements Controller { | ||
private final Repository repository = MemoryUserRepository.getInstance(); |
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 객체로 바꿀 때 이 부분을 수정해야하거든요
|
||
@Override | ||
public void execute(HttpRequest request, HttpResponse response) throws Exception { | ||
Map<String, String> params = request.getBody() != null ? HttpRequestUtils.parseQueryParameter(request.getBody()) : null; |
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.
파라미터를 파싱하는 부분은 httpRequest에서 처리해보는 건 어떨까요?
this.body = body; | ||
} | ||
|
||
public static HttpRequest from(BufferedReader br) throws IOException { |
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.
생성자와 팩토리 메소드의 작업이 명확히 나뉜 점 좋은 것 같아요. 그런데 httpRequest 객체의 책임이 커져서 팩토리 메소드의 길이가 길어지는 것 같아 보여요. httpRequest객체에서 구성을 이용해서 startline, header 객체를 갖도록 해보면 어떨까요? 그러면 책임을 잘 분산할 수 있지 않을까요?
public void forward(String path) throws IOException { | ||
byte[] body = Files.readAllBytes(Paths.get("webapp" + path)); | ||
dos.writeBytes("HTTP/1.1 " + OK.getValue() + "\r\n"); | ||
dos.writeBytes(CONTENT_TYPE.getValue() + ": text/html;charset=utf-8\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.
forward는 html만 처리하나요...?
if (params != null) { | ||
User user = repository.findUserById(params.get(USERID.getValue())); | ||
if (user != null && user.getPassword().equals(params.get(PASSWORD.getValue()))) { | ||
response.redirect(INDEX_PAGE.getValue()); |
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.
Set-cookie는 어디서 하는 걸까요...?
No description provided.