GET
- 콘텐츠를 조회
- 서버에 전송하고 싶은 데이터는 쿼리로 전달
- 바디로 데이터를 전달할 수 있지만, 지원하지 않는 곳이 많아서 지양
요청
GET /members/100 HTTP/1.1
Host: localhost:8080
응답
HTTP/1.1 200
Content-Type: application/json
...
{
"username": "kim",
"age": 20
}
...
POST
- 콘텐츠를 등록
- 프로세스를 처리
- 다른 메서드로 처리하기 애매한 경우
- ex) JSON으로 조회 데이터를 넘겨야 하는데, GET 메서드를 사용하기 어려운 경우
- 서버에 전송하고 싶은 데이터는 바디로 전달
요청
POST /members HTTP/1.1
Content-Length: 36
Content-Type: application/json
Host: localhost:8080
{
"username": "kim",
"age": 20
}
응답
HTTP/1.1 200
Content-Length: ...
...
PUT
요청
PUT /members/100 HTTP/1.1
Content-Length: 36
Content-Type: application/json
Host: localhost:8080
{
"username": "yoo",
"age": 27
}
응답
HTTP/1.1 200
Content-Length: ...
...
PATCH
요청
PATCH /members/100 HTTP/1.1
Content-Length: 36
Content-Type: application/json
Host: localhost:8080
{
"age": 27
}
응답
HTTP/1.1 200
Content-Length: ...
...
DELETE
요청
DELETE /members/100 HTTP/1.1
Host: localhost:8080
응답
HTTP/1.1 200
Content-Length: ...
...
참고자료