forked from codetree21/tsd-study
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb13565
commit ff3ca5d
Showing
2 changed files
with
34 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# 17. Building REST APIs With Django REST Framework | ||
|
||
DRF가 성공할 수 있었던 이유 | ||
- DRF는 객체 지향 설계에 의존하며 쉽게 확장되도록 설계되었다. | ||
- DRF는 Django의 CBV에서 바로 빌드되므로 CBV를 이해하면 DRF의 디자인을 Django의 확장처럼 느낄 수 있다. | ||
- django.views.generic.View에 가까운 기본적인 APIView에서부터 고도로 추상화된 generic API view들과 viewsets까지 다양한 view들이 제공된다. | ||
- serializer가 매우 강력하지만 사용하지 않거나 대체될 수도 있다. | ||
- 인증과 권한부여를 다루는 강력하고 확장가능한 방법을 제공한다. | ||
- FBV를 API를 위해 꼭 사용하고 싶다면 그러한 방법도 사용 가능하다. | ||
|
||
## 17.1 Fundamentals of Basic REST API Design | ||
|
||
|용도|HTTP Method|대응 SQL| | ||
|--|--|--| | ||
|자원 생성|POST|INSERT| | ||
|기존 자원 읽기|GET|SELECT| | ||
|기존 자원 업데이트|PUT|UPDATE| | ||
|기존 자원 수정|PATCH|UPDATE| | ||
|기존 자원 삭제|DELETE|DELETE| | ||
|GET과 동일한 Header를 body없이 반환|HEAD|| | ||
|요청하는 URL에서 지원하는 HTTP Method 반환|OPTIONS|| | ||
|요청을 그대로 반환|TRACE|| | ||
|
||
참고사항: | ||
- Read-Only API를 개발한다면 GET만 구현 | ||
- Read-Write API를 개발한다면 GET,POST,PUT 그리고 DELETE를 구현 | ||
- 모든 작업을 GET, POST에 대응시키는 것은 사용자 입장에서 좋지않은 패턴 | ||
- 정의상, GET, PUT, DELETE는 idempotent. POST와 PATCH는 그렇지 않다. | ||
- PATCH는 보통 구현되지 않는 편이지만, PUT을 구현했다면 같이 구현하는게 좋다. | ||
- DRF 역시 이러한 방법을 중심으로 설계되어있다. | ||
|
||
## 17.2 Illustrating Design Concepts With a Simple API | ||
|
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