-
Notifications
You must be signed in to change notification settings - Fork 309
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, 4단계] 아코(안석환) 미션 제출합니다. #466
Changes from 3 commits
14f7c5b
123e9ec
510ece5
c26d93e
892e483
43f4e6b
bf95275
b0432f0
7b7d619
54f2480
ea39cdc
f1f9360
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,28 @@ | ||||||||||||
package org.apache.coyote.http11; | ||||||||||||
|
||||||||||||
import java.util.HashMap; | ||||||||||||
import java.util.Map; | ||||||||||||
import org.apache.coyote.http11.controller.Controller; | ||||||||||||
import org.apache.coyote.http11.controller.LoginController; | ||||||||||||
import org.apache.coyote.http11.controller.PageController; | ||||||||||||
import org.apache.coyote.http11.controller.RegisterController; | ||||||||||||
import org.apache.coyote.http11.controller.RootController; | ||||||||||||
|
||||||||||||
public class RequestMapping { | ||||||||||||
|
||||||||||||
private static final Map<String, Controller> REQUEST_MAPPER = new HashMap<>(); | ||||||||||||
|
||||||||||||
Comment on lines
+13
to
+14
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
인스턴스를 만들지 않는 유틸 클래스에는 private 기본 생성자를 추가해주세요..!
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 빼먹고 추가를 못했었네요 감사합니다! |
||||||||||||
static { | ||||||||||||
REQUEST_MAPPER.put("/", new RootController()); | ||||||||||||
REQUEST_MAPPER.put("/login", new LoginController()); | ||||||||||||
REQUEST_MAPPER.put("/register", new RegisterController()); | ||||||||||||
} | ||||||||||||
|
||||||||||||
public static Controller getController(final String path) { | ||||||||||||
if (REQUEST_MAPPER.containsKey(path)) { | ||||||||||||
return REQUEST_MAPPER.get(path); | ||||||||||||
} | ||||||||||||
return new PageController(); | ||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
이 부분은 취향 차이라고 생각하는데 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 엄청 깔끔하네요! 배워갑니다 저도 if문이 없는 부분이 더 가독성이 좋은 것 같습니다👍👍 |
||||||||||||
} | ||||||||||||
|
||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,13 +1,13 @@ | ||||||
package org.apache.coyote.http11; | ||||||
|
||||||
import java.util.HashMap; | ||||||
import java.util.Map; | ||||||
import java.util.concurrent.ConcurrentHashMap; | ||||||
|
||||||
public class SessionManger { | ||||||
public class SessionManager { | ||||||
|
||||||
private static final Map<String, Session> SESSIONS = new HashMap<>(); | ||||||
private static final Map<String, Session> SESSIONS = new ConcurrentHashMap<>(); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
이건 저도 몰랐는데 인스턴스는 상수가 아니라고 하네요..! https://google.github.io/styleguide/javaguide.html#s5.2.4-constant-names There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 그렇네요 저도 이번에 처음 알았습니다 꼼꼼한 리뷰 감사합니다! |
||||||
|
||||||
private SessionManger() { | ||||||
private SessionManager() { | ||||||
|
||||||
} | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.apache.coyote.http11.controller; | ||
|
||
import org.apache.coyote.http11.httpmessage.request.HttpMethod; | ||
import org.apache.coyote.http11.httpmessage.request.HttpRequest; | ||
import org.apache.coyote.http11.httpmessage.response.HttpResponse; | ||
|
||
public abstract class AbstractController implements Controller { | ||
|
||
@Override | ||
public void service(final HttpRequest request, final HttpResponse response) throws Exception { | ||
if (request.getHttpMethod() == HttpMethod.POST) { | ||
doPost(request, response); | ||
} | ||
if (request.getHttpMethod() == HttpMethod.GET) { | ||
doGet(request, response); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. POST나 GET이 아닌 HttpMethod가 요청으로 들어오면 어떻게 될까요?? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 현재로서는 아무런 동작을 하지 않네요.. POST와 GET외에는 지원하지 메소드라는 예외처리를 진행하겠습니다. |
||
} | ||
|
||
protected void doPost(HttpRequest request, HttpResponse response) throws Exception { | ||
} | ||
|
||
protected void doGet(HttpRequest request, HttpResponse response) throws Exception { | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package org.apache.coyote.http11.controller; | ||
|
||
import org.apache.coyote.http11.httpmessage.request.HttpRequest; | ||
import org.apache.coyote.http11.httpmessage.response.HttpResponse; | ||
|
||
public interface Controller { | ||
|
||
void service(final HttpRequest request, final HttpResponse response) throws Exception; | ||
} |
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.
쓰레드와 동시성 관련한 테스트는 저도 아직 제대로 감을 잡지 못해서 찾아보는 중입니다 😥
같이 고민해보아요..
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.
저도 계속 찾아보았는데 방식이 떠오르지 않아서 이 부분 추가하지 못했습니다 ㅜㅜ