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조 이윤희 #19

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

Conversation

lylylylh
Copy link

@lylylylh lylylylh 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.

정말 고생하셨어요!! 고민과 노력이 보이는 코드였습니다 👍

public class HomeController implements Controller {
@Override
public void execute(HttpRequest request, HttpResponse response) throws Exception {
response.forward("/index.html");

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

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;

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 {

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

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

Choose a reason for hiding this comment

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

Set-cookie는 어디서 하는 걸까요...?

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