We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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 요청에 대한 Enum 추가합니다. String 값으로 값을 계속해서 비교하기 보다는 미리 Enum으로 선언하여 활용하도록 합니다.
POST("POST"), GET("GET"), PATCH("PATCH"), DELETE("DELETE");
2.요청으로부터 받은 URL에서 쿼리값을 추출합니다. 추출한 값은 = 와 &에 맞춰 key값과 value로 분류하여 Map에 저장하도록 합니다.
public static Map<String, String> parseQueryString(final String queryString) { Map<String, String> result = new HashMap<>(); String[] splintedQuery = queryString.split("&"); for(String sentence : splintedQuery) { String[] query = sentence.split("="); String key = query[0]; String value = query[1]; result.put(key, value); } return result; }
public static String readData(final BufferedReader br, final int contentLength) throws IOException { char[] body = new char[contentLength]; br.read(body, 0, contentLength); return convertJsonToUrl(String.copyValueOf(body)); } public static String convertJsonToUrl(final String json) { StringBuffer sb = new StringBuffer(); String[] keyValuePairs = json.replaceAll("[{}\"]", "").split(","); for (String pair : keyValuePairs) { String[] keyValue = pair.split(":"); String key = keyValue[0].trim(); String value = keyValue[1].trim(); sb.append(key).append("=").append(value).append("&"); } sb.deleteCharAt(sb.length() - 1); return sb.toString(); }
//POST if(HttpRequestMethod.POST.equals(method) && url.equals("/users/create")) { //GET else if(HttpRequestMethod.GET.equals(method) && url.startsWith("/users")) {
public class User { private final String userId; private final String password; private final String name; private final String email;
The text was updated successfully, but these errors were encountered:
feat(RequestHandler) : POST와 GET 요청에 대해 동적으로 응답할 수 있도록 핸들러 구현
b2e7dba
#3
feat(User) : 회원 객체 구현
13735b6
feat(IOUtils) : 받은 Json 값을 QueryString으로 변환하는 클래스 구현
1653a54
feat(HttpRequestUtils) : 쿼리스트링 값을 Map으로 반환하는 메서드를 가진 클래스 구현
73c44c0
feat(HttpRequestUtils) : HTTP 요청에 대한 Enum 추가
9381ff5
mjj111
No branches or pull requests
📄 구현 포인트
✅ 간략한 코드 설명
1.HTTP 요청에 대한 Enum 추가합니다.
String 값으로 값을 계속해서 비교하기 보다는 미리 Enum으로 선언하여 활용하도록 합니다.
2.요청으로부터 받은 URL에서 쿼리값을 추출합니다.
추출한 값은 = 와 &에 맞춰 key값과 value로 분류하여 Map에 저장하도록 합니다.
받은 Json 값을 QueryString으로 변환하도록 합니다.
The text was updated successfully, but these errors were encountered: