REST API
-
Rest API 설계 기본 팁 : 계층 구조에 대한 식별자를 명확히 하기개발 나누고 더하기/기타 2023. 7. 25. 22:28
시스템을 설계하다보면 1:1 또는 1:N 관계로 계층 모델이 많이 나온다. 이커머스를 예로 들면 상품과 하위 아이템인 경우인데, 상품에 상품명(PSG 이강인 티셔츠), 상세 설명(상세 이미지)와 같은 정보를 담고, 이 상품을 참조하는 아이템에는 사이즈(S, M, L)와 재고 등을 담는 구조이다. 백오피스 같은 관리 시스템에서 상품과 아이템별로 관리해야 하는 요구가 있다고 치자. 이를 조회하는 API 스펙은 대충 다음과 같이 나올 수 있다. 상품 조회 API url : {host}/api/v1/goods/{id} method : GET param : id - 상품 ID response : name - 상품명, description - 상세 설명 아이템 조회 API url : {host}/api/v1/goo..