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

[제이] 1단계 - HTTP 웹 서버 리팩터링 미션 제출합니다. #198

Merged
merged 24 commits into from
Nov 17, 2020

Conversation

jjj0611
Copy link

@jjj0611 jjj0611 commented Nov 15, 2020

안녕하세요 하비,
리뷰 요청이 늦어서 죄송합니다. 😢
HTTP 1단계 요구사항에 맞게 간단히 구현해보았습니다.
아직 객체 분리가 더 필요한 부분이 많은데,
일단 1단계 요청 드리고, 계속해서 분리해나가도록 하겠습니다. 😭

리뷰 감사합니다!


11월 17일 기준 수정

1단계 요청을 드리고 나서 크루와 함께 페어를 하다보니 2단계까지 이 PR에 들어오게 되었어요ㅠ
혹시 괜찮으시다면 하비가 남겨주는 리뷰를 반영하는 것으로 2단계를 갈음해도 괜찮을까요?
2단계까지 중에 더 구현해야 할 사항이 있거나 부족해 보이는 부분을 말씀해주시면 2단계 요청에 반영하도록 하겠습니다 :)

많은 양을 한 번에 리뷰 드려 죄송합니다. 😭

@jjj0611 jjj0611 changed the title [제이] 1단계 - HTTP 웹 서버 리팩토링 미션 제출합니다. [제이] 1단계 - HTTP 웹 서버 리팩터링 미션 제출합니다. Nov 16, 2020
Copy link

@young891221 young891221 left a comment

Choose a reason for hiding this comment

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

안녕하세요, 제이!
어제 보다가 한번 더 봐야지 했다가 어제 장애가 나서 못봤네요ㅠㅠ
코드가 많이 달라졌는데 말씀하신데로 한번에 피드백하도록 하겠습니다.
리뷰 반영 부탁드려요 ㅎ

import model.User;

@RequestMapping(path = "/user")
public class UserController extends AbstractController {

Choose a reason for hiding this comment

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

지원되는 메서드만 남기고 지원되지 않는 메서드는 굳이 오버라이드 되지 않는 구조를 만들어 보는게 좋을것 같습니다~!

Comment on lines +50 to +61
HttpServlet dispatcherServlet = new DispatcherServlet();
HttpRequest httpRequest = SimpleHttpRequest.of(bufferedReader);
logger.debug(System.lineSeparator() + httpRequest.toString());
HttpResponse httpResponse = new HttpResponse();
if (StaticResourceMatcher.isStaticResourcePath(httpRequest.getURI())) {
byte[] body = FileIoUtils.loadFileFromClasspath(httpRequest.getURI());
ContentType contentType = ContentType.findByURI(httpRequest.getURI());
httpResponse.setBody(body, contentType);
} else {
dispatcherServlet.service(httpRequest, httpResponse);
}
httpResponse.send(dos);

Choose a reason for hiding this comment

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

resource 처리 영역과 아닌 영역 명확하게 분리하여 response를 반환하도록 구조를 변경해 보면 어떨까요ㅎ

return Files.readAllBytes(getPathByExtension(filePath));
}

private static Path getPathByExtension(String filePath) throws URISyntaxException {

Choose a reason for hiding this comment

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

html이나 원하는 resource postfix 형식이 아닐때에 대한 테스트도 작성 부탁드려요!

@young891221 young891221 merged commit 275fc42 into woowacourse:jjj0611 Nov 17, 2020
jeonghoon1107 pushed a commit that referenced this pull request Nov 20, 2020
* docs: README.md에 요구사항 1 추가

* feat: Request Handler에서 Header 추출 기능 구현

* feat: request의 path로 파일을 읽어서 응답하는 기능 추가

* feat: Http Request 생성

	- Http Method를 위한 클래스 생성
	- Http Status를 위한 클래스 생성
	- Http Header를 위한 클래스 생성

* feat: 요구사항1 완료

* docs: 두번째 요구사항 작성

* refactoring: http spec 정의

* refactoring: http request spec 추가 및 테스트 추가

* refactor: http request spec 변경

* feat: 요구사항2 완료

* docs: 요구사항3을 위한 README.md 작성

* feat: 회원 가입 기능이 post 요청에서 정상적으로 동작하도록 구현

* docs: 요구사항4 작성

* feat: 회원가입 완료 후 index.html로 이동하도록 변경

* docs: 요구사항 5 README.md에 작성

* feat: 요청 uri이 static resource인지를 확인하는 기능 생성

* feat: stylesheet 등 다양한 형식의 파일을 지원하도록 변경

* feat: Http Response 분리

* test: SimpleHttRequest에 대한 Test 작성

* test: HttpResponse에 대한 Test 작성

* refactor: HttpServlet 및 UserController 생성

* feat: DispatcherServlet 생성

* feat: ThreadPool 사용

* docs: 구현 내용 정리

* refactor: 사용하지 않는 파일 삭제

* [제이] 1단계 - HTTP 웹 서버 리팩터링 미션 제출합니다. (#198)

* docs: README.md에 요구사항 1 추가

* feat: Request Handler에서 Header 추출 기능 구현

* feat: request의 path로 파일을 읽어서 응답하는 기능 추가

* feat: Http Request 생성

	- Http Method를 위한 클래스 생성
	- Http Status를 위한 클래스 생성
	- Http Header를 위한 클래스 생성

* feat: 요구사항1 완료

* docs: 두번째 요구사항 작성

* refactoring: http spec 정의

* refactoring: http request spec 추가 및 테스트 추가

* refactor: http request spec 변경

* feat: 요구사항2 완료

* docs: 요구사항3을 위한 README.md 작성

* feat: 회원 가입 기능이 post 요청에서 정상적으로 동작하도록 구현

* docs: 요구사항4 작성

* feat: 회원가입 완료 후 index.html로 이동하도록 변경

* docs: 요구사항 5 README.md에 작성

* feat: 요청 uri이 static resource인지를 확인하는 기능 생성

* feat: stylesheet 등 다양한 형식의 파일을 지원하도록 변경

* feat: Http Response 분리

* test: SimpleHttRequest에 대한 Test 작성

* test: HttpResponse에 대한 Test 작성

* refactor: HttpServlet 및 UserController 생성

* feat: DispatcherServlet 생성

* feat: ThreadPool 사용

* docs: 구현 내용 정리

* docs: 2단계 리팩토링 목록 작성

* refactor: AbstractController 수정
- 지원하지 않는 메서드에 대해서는 MethodNotAllowed 응답 반환

* refactor: resource 처리 영역과 아닌 영역을 구분

* test: 다양한 resource postfix 형식에 대한 테스트 작성

Co-authored-by: jaeju.jang <jjj0611@gmail.com>
Co-authored-by: Jang Jaeju <44603719+jjj0611@users.noreply.github.com>
young891221 pushed a commit that referenced this pull request Nov 26, 2020
* [또링] 1단계 - HTTP 웹 서버 구현 미션 제출합니다. (#105)

* docs : 요구사항1의 구현 기능 목록 작성

* feat : 모든 Request Header 출력하기

* feat : Request에서 path 분리하기

* feat : path에 해당하는 파일 읽어 응답하기

* docs : 요구사항2의 구현 기능 목록 작성

* feat : Request Parameter 추출 및 User 객체 생성

* docs : 요구사항3의 구현 기능 목록 작성

* feat : form.html 파일의 form 태그 method를 get에서 post로 수정

* refactor : HttpRequest를 RequestHeader와 RequestBody로 분리

* refactor : HttpRequestParser 유틸 클래스 생성

* docs : 요구사항4의 구현 기능 목록 작성

* feat : 요청에 따라 다른 HttpResponse를 내려준다.

* docs : 요구사항5의 구현 기능 목록 작성

* refactor : RequestHeader 값의 자료형을 List에서 Map으로 변경

* refactor : HeaderProperty 생성

* feat : 응답에 따라 Content-Type을 변경하여 Stylesheet 파일을 지원하도록 구현

* feat : status code를 302로 변경한 후, Location 값에 리다이렉션 할 페이지를 넣어 응답

* refactor : 변수 정리 및 파일 끝 개행 추가

* docs: 3단계 요구사항1 구현 기능목록 작성

* feat: 로그인 기능 구현

* feat: default root 설정

* docs: 요구사항 2번째 기능 목록 작성

* test: handlebar 사용을 위한 학습테스트 작성

* feat: 로그인하지 않은 상태면 로그인 페이지로 이동

* feat: 유저 목록 출력하기

* feat: 로그인 성공 여부에 따라 페이지 redirect

* refactor: http package 구조 변경

* test: /user GET method에 대한 테스트 작성

* [또링] 2단계 - HTTP 웹 서버 리팩터링 미션 제출합니다. (#202)

* docs: README.md에 요구사항 1 추가

* feat: Request Handler에서 Header 추출 기능 구현

* feat: request의 path로 파일을 읽어서 응답하는 기능 추가

* feat: Http Request 생성

	- Http Method를 위한 클래스 생성
	- Http Status를 위한 클래스 생성
	- Http Header를 위한 클래스 생성

* feat: 요구사항1 완료

* docs: 두번째 요구사항 작성

* refactoring: http spec 정의

* refactoring: http request spec 추가 및 테스트 추가

* refactor: http request spec 변경

* feat: 요구사항2 완료

* docs: 요구사항3을 위한 README.md 작성

* feat: 회원 가입 기능이 post 요청에서 정상적으로 동작하도록 구현

* docs: 요구사항4 작성

* feat: 회원가입 완료 후 index.html로 이동하도록 변경

* docs: 요구사항 5 README.md에 작성

* feat: 요청 uri이 static resource인지를 확인하는 기능 생성

* feat: stylesheet 등 다양한 형식의 파일을 지원하도록 변경

* feat: Http Response 분리

* test: SimpleHttRequest에 대한 Test 작성

* test: HttpResponse에 대한 Test 작성

* refactor: HttpServlet 및 UserController 생성

* feat: DispatcherServlet 생성

* feat: ThreadPool 사용

* docs: 구현 내용 정리

* refactor: 사용하지 않는 파일 삭제

* [제이] 1단계 - HTTP 웹 서버 리팩터링 미션 제출합니다. (#198)

* docs: README.md에 요구사항 1 추가

* feat: Request Handler에서 Header 추출 기능 구현

* feat: request의 path로 파일을 읽어서 응답하는 기능 추가

* feat: Http Request 생성

	- Http Method를 위한 클래스 생성
	- Http Status를 위한 클래스 생성
	- Http Header를 위한 클래스 생성

* feat: 요구사항1 완료

* docs: 두번째 요구사항 작성

* refactoring: http spec 정의

* refactoring: http request spec 추가 및 테스트 추가

* refactor: http request spec 변경

* feat: 요구사항2 완료

* docs: 요구사항3을 위한 README.md 작성

* feat: 회원 가입 기능이 post 요청에서 정상적으로 동작하도록 구현

* docs: 요구사항4 작성

* feat: 회원가입 완료 후 index.html로 이동하도록 변경

* docs: 요구사항 5 README.md에 작성

* feat: 요청 uri이 static resource인지를 확인하는 기능 생성

* feat: stylesheet 등 다양한 형식의 파일을 지원하도록 변경

* feat: Http Response 분리

* test: SimpleHttRequest에 대한 Test 작성

* test: HttpResponse에 대한 Test 작성

* refactor: HttpServlet 및 UserController 생성

* feat: DispatcherServlet 생성

* feat: ThreadPool 사용

* docs: 구현 내용 정리

* docs: 2단계 리팩토링 목록 작성

* refactor: AbstractController 수정
- 지원하지 않는 메서드에 대해서는 MethodNotAllowed 응답 반환

* refactor: resource 처리 영역과 아닌 영역을 구분

* test: 다양한 resource postfix 형식에 대한 테스트 작성

Co-authored-by: jaeju.jang <jjj0611@gmail.com>
Co-authored-by: Jang Jaeju <44603719+jjj0611@users.noreply.github.com>

* docs: 3단계 요구사항3 구현 기능 목록 작성

* feat: HttpSession 인터페이스 작성

* feat: SimpleHttpSession 구현체 작성

* feat: httpSession을 적용하여 로그인 구현

* feat: Cookie 객체 분리

* refactor: Cookies 생성

* refactor: 지원하지 않는 메서드에 대해서 MethodNotAllowed를 응답하도록 변경

* refactor: 테스트용 request 파일명 변경

* test: UserServiceTest#findAll 테스트 작성

* refactor: HttpVersion 객체 분리

* docs : 3단계 리팩터링 목록 작성

* refactor : 인코딩 실패 시 errorStack 출력 -> InternalServerError 반환

* refactor : null 반환 제거

* refactor : doGet() 템플릿화하어 재사용 가능한 구조를 만들기

* refactor : 로그인 검증에 대한 부분을 분리하여 재사용 가능하도록 변경

Co-authored-by: 또링 <jnsorn@gmail.com>
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.

None yet

2 participants