작업 이유
현재 방식의 URL로는 자원의 나타냄이 부족하다고 느껴져서, URL을 변경하려고 합니다.
resource의 식별 -> 패스 파라미터, 조건(정렬 및 필터) -> 쿼리파라미터를 사용
- 쿼리파라미터 위주의 방식 -> 패스 파라미터 위주의 방식
- body값에 고유id(content_id 등) 를 담는 방식 -> 패스 파라미터로 고유id(content_id 등) 사용으로 변경
- Swagger 사용 시 보다 확실한 정보를 알 수 있게 문서화 작업
변경 예정 사항
현재 URL -> 변경 URL
Content
- [GET] :
/api/v1/contents?id={content_id} -> /api/v1/contents/{content_id}
- [POST] :
/api/v1/contents -> /api/v1/contents (그대로)
- [PATCH] :
/api/v1/contents -> /api/v1/contents/{content_id}
- [DELETE] :
/api/v1/contents -> /api/v1/contents/{content_id}
Comment
/api/v1/comments로 작성하였을 시, DB상의 모든 댓글에 대한 내용이 되므로 특정 게시글의 댓글로 판단하기 어렵다고 생각되어, 게시글 번호를 받는 부분을 추가하였습니다.
- [GET] :
/api/v1/comments?contentId={contentId} -> /api/v1/contents/{content_id}/comments
- [POST] :
/api/v1/comments -> /api/v1/contents/{content_id}/comments
- [PATCH] :
/api/v1/comments -> /api/v1/contents/{content_id}/comments/{comment_id}
- [DELETE] :
/api/v1/comments -> /api/v1/contents/{content_id}/comments/{comment_id}
ContentMark
- [GET] :
/api/v1/mark?contentId={content_id} -> /api/v1/contents/{content_id}/marks
- [POST] :
/api/v1/mark -> [GET] /api/v1/contents/{content_id}/marks/my
- [PATCH] :
/api/v1/mark -> /api/v1/contents/{content_id}/marks/{contentMark_id}
- [DELETE] :
/api/v1/mark -> /api/v1/contents/{content_id}/marks/{contentMark_id}
ContentCategory
- [GET] :
/api/v1/category?contentId={content_id} -> /api/v1/contents/{content_id}/categories
- [PATCH] :
/api/v1/category -> /api/v1/contents/{content_id}/categories
- [DELETE] :
/api/v1/category -> /api/v1/contents/{content_id}/categories
할일
작업 이유
현재 방식의 URL로는 자원의 나타냄이 부족하다고 느껴져서, URL을 변경하려고 합니다.
resource의 식별 -> 패스 파라미터, 조건(정렬 및 필터) -> 쿼리파라미터를 사용
변경 예정 사항
현재 URL -> 변경 URL
Content
/api/v1/contents?id={content_id}->/api/v1/contents/{content_id}/api/v1/contents->/api/v1/contents (그대로)/api/v1/contents->/api/v1/contents/{content_id}/api/v1/contents->/api/v1/contents/{content_id}Comment
/api/v1/comments로 작성하였을 시, DB상의 모든 댓글에 대한 내용이 되므로 특정 게시글의 댓글로 판단하기 어렵다고 생각되어, 게시글 번호를 받는 부분을 추가하였습니다.
/api/v1/comments?contentId={contentId}->/api/v1/contents/{content_id}/comments/api/v1/comments->/api/v1/contents/{content_id}/comments/api/v1/comments->/api/v1/contents/{content_id}/comments/{comment_id}/api/v1/comments->/api/v1/contents/{content_id}/comments/{comment_id}ContentMark
/api/v1/mark?contentId={content_id}->/api/v1/contents/{content_id}/marks/api/v1/mark-> [GET]/api/v1/contents/{content_id}/marks/my/api/v1/mark->/api/v1/contents/{content_id}/marks/{contentMark_id}/api/v1/mark->/api/v1/contents/{content_id}/marks/{contentMark_id}ContentCategory
/api/v1/category?contentId={content_id}->/api/v1/contents/{content_id}/categories/api/v1/category->/api/v1/contents/{content_id}/categories/api/v1/category->/api/v1/contents/{content_id}/categories할일