-
Notifications
You must be signed in to change notification settings - Fork 311
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[1단계 - Tomcat 구현하기] 알파카(최휘용) 미션 제출합니다. (#568)
* fix: remove implementation logback-classic on gradle (#501) * fix: add threads min-spare configuration on properties (#502) * feat: 정적 파일의 내용 GET 기능 구현 * feat: response에 Content-type 지정 기능 구현 * feat: HttpResponse 구현 * feat: HttpRequest 구현 * feat: cache 학습 테스트 코드 구현 * feat: GET login 기능 구현 * feat: cache 테스트 4번 구현 * feat: header 필드 및 파싱 기능 구현 --------- Co-authored-by: Gyeongho Yang <[email protected]>
- Loading branch information
1 parent
0b698a2
commit d45988c
Showing
13 changed files
with
254 additions
and
38 deletions.
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 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
16 changes: 12 additions & 4 deletions
16
study/src/main/java/cache/com/example/etag/EtagFilterConfiguration.java
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 |
---|---|---|
@@ -1,12 +1,20 @@ | ||
package cache.com.example.etag; | ||
|
||
import static cache.com.example.version.CacheBustingWebConfig.PREFIX_STATIC_RESOURCES; | ||
|
||
import org.springframework.boot.web.servlet.FilterRegistrationBean; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.filter.ShallowEtagHeaderFilter; | ||
|
||
@Configuration | ||
public class EtagFilterConfiguration { | ||
|
||
// @Bean | ||
// public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() { | ||
// return null; | ||
// } | ||
@Bean | ||
public FilterRegistrationBean<ShallowEtagHeaderFilter> shallowEtagHeaderFilter() { | ||
FilterRegistrationBean<ShallowEtagHeaderFilter> filterRegistrationBean = | ||
new FilterRegistrationBean<>(new ShallowEtagHeaderFilter()); | ||
filterRegistrationBean.addUrlPatterns("/etag/*", PREFIX_STATIC_RESOURCES + "/*"); | ||
return filterRegistrationBean; | ||
} | ||
} |
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 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 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 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
26 changes: 26 additions & 0 deletions
26
tomcat/src/main/java/com/techcourse/controller/Controller.java
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,26 @@ | ||
package com.techcourse.controller; | ||
|
||
import com.techcourse.db.InMemoryUserRepository; | ||
import org.apache.coyote.http11.HttpRequest; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
public class Controller { | ||
|
||
private static final Logger LOGGER = LoggerFactory.getLogger(Controller.class); | ||
|
||
public Controller() { | ||
} | ||
|
||
public String getLogin(HttpRequest request) { | ||
String requestAccount = request.getQueryStringData("account"); | ||
String requestPassword = request.getQueryStringData("password"); | ||
InMemoryUserRepository.findByAccount(requestAccount) | ||
.ifPresent(user -> { | ||
if (user.checkPassword(requestPassword)) { | ||
LOGGER.info(user.toString()); | ||
} | ||
}); | ||
return "/login.html"; | ||
} | ||
} |
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 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
33 changes: 33 additions & 0 deletions
33
tomcat/src/main/java/org/apache/coyote/http11/HttpRequest.java
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,33 @@ | ||
package org.apache.coyote.http11; | ||
|
||
import java.util.Map; | ||
|
||
public class HttpRequest { | ||
|
||
private final String method; | ||
private final String path; | ||
private final Map<String, String> queryString; | ||
private final String protocolVersion; | ||
private final Map<String, String> headers; | ||
|
||
public HttpRequest(String method, String path, Map<String, String> queryString, String protocolVersion, | ||
Map<String, String> headers) { | ||
this.method = method; | ||
this.path = path; | ||
this.queryString = queryString; | ||
this.protocolVersion = protocolVersion; | ||
this.headers = headers; | ||
} | ||
|
||
public String getQueryStringData(String input) { | ||
return queryString.get(input); | ||
} | ||
|
||
public String getPath() { | ||
return this.path; | ||
} | ||
|
||
public String getMethod() { | ||
return this.method; | ||
} | ||
} |
Oops, something went wrong.