# Representational State Transfer

> REST (Representational State Transfer) is a software architectural style that was created to describe the design and guide the development of the architecture for the World Wide Web.

REST (Representational State Transfer) is a software architectural style that was created to describe the design and guide the development of the <architecture> for the <World Wide Web>.

Introduced and defined in <2000> by computer scientist <Roy Fielding>.

## Resource Oriented Architecture에 대한 이해를 돕기 좋은 예시

`POST /login`, `POST /logout`:

- 리소스는 동사가 아니라 명사이면 좋고, 되도록 HTTP 표준 동사를 의미에 맞게 사용하면 좋음
- 개선 예: `PUT /session`, `DELETE /session`

`POST /bookmarks/toggleBookmark?id=123`:

- toggle은 호출을 몇 번 하느냐에 따라 서버 측 리소스의 상태가 달라지기 때문에 idempotent 하지 않음.
- `POST /bookmarks/123/add`, `POST /bookmarks/123/remove`로 바꾸면 조금 나아짐. 한편, 이 방식도 리소스에 동사(add, remove)가 담긴다는 점에서 아주 좋지는 않음.
- 더 개선하면? `PUT /bookmarks/123`, `DELETE /bookmarks/123`