-
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
[톰캣 구현하기 1, 2단계] 마코(이규성) 미션 제출합니다. #332
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
9303da4
feat: 1단계 - HTTP 서버 구현하기
aak2075 a9f593d
feat: 2단계 - 1.HTTP Status Code 302
aak2075 f64db47
feat: 2단계 - 2. POST 방식으로 회원가입
aak2075 2b05c7c
feat: 2단계 - 3,4 Cookie에 JSESSIONID 값 저장하기 및 Session 구현하기
aak2075 3069ea7
refactor: 개행 정리 및 불필요한 메서드 제거
aak2075 dc50303
refactor: 상수 대문자로 변경
aak2075 00417a7
refactor: 뷰 리졸버 분리 리팩토링
aak2075 7bc374c
refactor: RequestBuilder 도입
aak2075 91004b2
refactor: 사용하지 않는 import 제거
aak2075 d24f44f
refactor: 패키지 이동
aak2075 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package nextstep.mvc; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
public class ModelAndView { | ||
|
||
private final String viewName; | ||
private final Map<String, String> model = new HashMap<>(); | ||
Comment on lines
+6
to
+9
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. 좋은데요? |
||
|
||
public ModelAndView(final String viewName) { | ||
this.viewName = viewName; | ||
} | ||
|
||
public ModelAndView() { | ||
this(null); | ||
} | ||
|
||
public void setAttribute(String key, String value) { | ||
model.put(key, value); | ||
} | ||
|
||
public String getViewName() { | ||
return viewName; | ||
} | ||
|
||
public Map<String, String> getModel() { | ||
return model; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package nextstep.mvc; | ||
|
||
import java.util.Map; | ||
import org.apache.coyote.http11.HttpHeaders; | ||
import org.apache.coyote.http11.HttpResponse; | ||
|
||
public class View { | ||
|
||
private static final String DEFAULT_CHAR_SET = "text/html;charset=utf-8"; | ||
|
||
private String content; | ||
private final String contentType; | ||
|
||
public View() { | ||
this.contentType = DEFAULT_CHAR_SET; | ||
} | ||
|
||
public View(final String content, final String contentType) { | ||
this.content = content; | ||
this.contentType = contentType; | ||
} | ||
|
||
public void render(Map<String, String> model, HttpResponse httpResponse) { | ||
if (content == null) { | ||
StringBuilder sb = new StringBuilder(); | ||
for (final var value : model.values()) { | ||
sb.append(value); | ||
} | ||
httpResponse.addHeader(HttpHeaders.CONTENT_TYPE, DEFAULT_CHAR_SET); | ||
httpResponse.addHeader(HttpHeaders.CONTENT_LENGTH, | ||
String.valueOf(sb.toString().getBytes().length)); | ||
httpResponse.setBody(sb.toString()); | ||
return; | ||
} | ||
Comment on lines
+24
to
+34
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. early return 👍 |
||
|
||
httpResponse.addHeader(HttpHeaders.CONTENT_TYPE, contentType); | ||
httpResponse.addHeader(HttpHeaders.CONTENT_LENGTH, | ||
String.valueOf(content.getBytes().length)); | ||
httpResponse.setBody(content); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package nextstep.mvc; | ||
|
||
import common.FileReader; | ||
import java.io.IOException; | ||
import org.apache.coyote.http11.SupportContentType; | ||
|
||
public class ViewResolver { | ||
|
||
private ViewResolver() { | ||
} | ||
|
||
public static View resolve(final String viewName) throws IOException { | ||
return new View(FileReader.readFile(viewName), SupportContentType.getContentType(viewName)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
DEFAULT_FILE_EXTENSION 은 어떤가요?!
기본 확장자가 .html인걸 더 잘 알려주는 것 같아요!