-
Notifications
You must be signed in to change notification settings - Fork 309
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: RequestLine의 httpMethod enum으로 변경 및 커스텀 예외 추가
- Loading branch information
Showing
3 changed files
with
41 additions
and
6 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
tomcat/src/main/java/org/apache/coyote/http11/exception/InvalidRequestException.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,8 @@ | ||
package org.apache.coyote.http11.exception; | ||
|
||
public class InvalidRequestException extends RuntimeException { | ||
|
||
public InvalidRequestException() { | ||
super("유효하지 않은 요청입니다."); | ||
} | ||
} |
15 changes: 9 additions & 6 deletions
15
tomcat/src/main/java/org/apache/coyote/http11/request/RequestLine.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
24 changes: 24 additions & 0 deletions
24
tomcat/src/main/java/org/apache/coyote/http11/request/RequestMethod.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,24 @@ | ||
package org.apache.coyote.http11.request; | ||
|
||
import org.apache.coyote.http11.exception.InvalidRequestException; | ||
|
||
import java.util.Arrays; | ||
|
||
public enum RequestMethod { | ||
GET, | ||
POST, | ||
PATCH, | ||
UPDATE, | ||
DELETE, | ||
; | ||
|
||
RequestMethod() { | ||
} | ||
|
||
public static RequestMethod getRequestMethod(String value) { | ||
return Arrays.stream(RequestMethod.values()) | ||
.filter(requestMethod -> requestMethod.name().equals(value)) | ||
.findFirst() | ||
.orElseThrow(InvalidRequestException::new); | ||
} | ||
} |