-
Notifications
You must be signed in to change notification settings - Fork 1
/
rest.comment.example.http
142 lines (136 loc) · 5.88 KB
/
rest.comment.example.http
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
###
# 댓글 조회, 검색
#
# - 검색어가 있을 경우 검색된 댓글 목록 반환 / 없을 경우 댓글 목록 반환
# ------------------------------------------------------------------------------
# GET /api/v1/board/{boardName}/post/{postId}/comment?parent={parent}&page={page}&query={query} HTTP/1.1
# Content-Type: application/json
# Accept: application/json
# ------------------------------------------------------------------------------
#
# @param string boardName 게시판 이름
# @param int postId 게시글 ID
# @param int|null parent 부모 댓글 ID (기본값 null)
# @param int page 페이지 번호(기본값 1) / 페이지당 Row수는 board table에 정의
# @param string query 검색어 (기본값 null)
#
GET http://localhost:12000/api/v1/board/free/post/105/comment HTTP/1.1
# GET http://localhost:12000/api/v1/board/free/post/105/comment?page=1 HTTP/1.1
# GET http://localhost:12000/api/v1/board/free/post/105/comment?page=1&query=학교 HTTP/1.1
# GET http://localhost:12000/api/v1/board/free/post/105/comment?parent=23 HTTP/1.1
Content-Type: application/json
Accept: application/json
###
# ID에 해당하는 댓글 조회
# ------------------------------------------------------------------------------
# GET /api/v1/board/{boardName}/post/{postId}/comment/{commentId} HTTP/1.1
# Content-Type: application/json
# Accept: application/json
# ------------------------------------------------------------------------------
#
# @param string boardName 게시판 이름
# @param int postId 게시글 ID
# @param int commentId 댓글 ID
#
GET http://localhost:12000/api/v1/board/free/post/105/comment/668 HTTP/1.1
Content-Type: application/json
Accept: application/json
###
# 댓글 등록
#
# - XSS Protection 적용되어 댓글 등록
# - 등록된 사용자만(users 테이블 모든 사용자만) 댓글 추가를 할 수 있음
# - 사용자 확인을 위해 HTTP 기본 인증(Basic Auth) 사용
# - CommentController - constructor - middleware 에서 인증 확인
# - Basic Auth의 email:password 를 base64인코딩하여 사용
# ex) Authorization: Basic base64Encode("laraboard@example.net:password")
# => Authorization: Basic bGFyYWJvYXJkQGV4YW1wbGUubmV0OnBhc3N3b3Jk
# ------------------------------------------------------------------------------
# POST /api/v1/board/{boardName}/post/{postId}/comment HTTP/1.1
# Content-Type: application/json
# Accept: application/json
# Authorization: Basic base64Encode(email:password)
#
# {
# content: {content}
# parent_comment_id: {parent_comment_id}
# }
# ------------------------------------------------------------------------------
#
# @param string boardName 게시판 이름
# @param int postId 게시글 ID
# @param string content 댓글 본문
# @param int parent_comment_id 부모 댓글 ID (기본값 null), 없으면 일반 댓글
#
# @see https://laravel.kr/docs/9.x/authentication#HTTP%20%EA%B8%B0%EB%B3%B8%20%EC%9D%B8%EC%A6%9D
#
POST http://localhost:12000/api/v1/board/free/post/105/comment HTTP/1.1
Content-Type: application/json
Accept: application/json
Authorization: Basic bGFyYWJvYXJkQGV4YW1wbGUubmV0OnBhc3N3b3Jk
{
"content": "<p>asdfasdf</p><br><p>가나다라</p>",
"parent_comment_id": null
}
###
# 댓글 수정
#
# - XSS Protection 적용되어 댓글 수정
# - 본인 댓글(users 테이블 등록된 본인 사용자)만 수정 할 수 있음
# - 본인 확인을 위해 HTTP 기본 인증(Basic Auth) 사용
# - CommentController - constructor - middleware 에서 인증 확인
# - Basic Auth의 email:password 를 base64인코딩하여 사용
# ex) Authorization: Basic base64Encode("laraboard@example.net:password")
# => Authorization: Basic bGFyYWJvYXJkQGV4YW1wbGUubmV0OnBhc3N3b3Jk
# ------------------------------------------------------------------------------
# PUT /api/v1/board/{boardName}/post/{postId}/comment/{commentId} HTTP/1.1
# Content-Type: application/json
# Accept: application/json
# Authorization: Basic base64Encode(email:password)
#
# {
# content: {content}
# }
# ------------------------------------------------------------------------------
#
# @param string boardName 게시판 이름
# @param int postId 게시글 ID
# @param int commentId 댓글 ID
# @param string content 댓글 본문
#
# @see https://laravel.kr/docs/9.x/authentication#HTTP%20%EA%B8%B0%EB%B3%B8%20%EC%9D%B8%EC%A6%9D
#
PUT http://localhost:12000/api/v1/board/free/post/105/comment/668 HTTP/1.1
Content-Type: application/json
Accept: application/json
Authorization: Basic bGFyYWJvYXJkQGV4YW1wbGUubmV0OnBhc3N3b3Jk
{
"content": "<p>2222asdfasdf</p><br><p>가나다라</p>"
}
###
# 댓글 삭제
#
# - 부모 댓글이 존재할 경우 삭제 불가
# - 본인 댓글(users 테이블 등록된 본인 사용자)만 삭제 할 수 있음
# - 본인 확인을 위해 HTTP 기본 인증(Basic Auth) 사용
# - CommentController - constructor - middleware 에서 인증 확인
# - Basic Auth의 email:password 를 base64인코딩하여 사용
# ex) Authorization: Basic base64Encode("laraboard@example.net:password")
# => Authorization: Basic bGFyYWJvYXJkQGV4YW1wbGUubmV0OnBhc3N3b3Jk
# ------------------------------------------------------------------------------
# DELETE /api/v1/board/{boardName}/post/{postId}/comment/{commentId} HTTP/1.1
# Content-Type: application/json
# Accept: application/json
# Authorization: Basic base64Encode(email:password)
# ------------------------------------------------------------------------------
#
# @param string boardName 게시판 이름
# @param int postId 게시글 ID
# @param int commentId 댓글 ID
#
# @see https://laravel.kr/docs/9.x/authentication#HTTP%20%EA%B8%B0%EB%B3%B8%20%EC%9D%B8%EC%A6%9D
#
DELETE http://localhost:12000/api/v1/board/free/post/105/comment/86 HTTP/1.1
Content-Type: application/json
Accept: application/json
Authorization: Basic bGFyYWJvYXJkQGV4YW1wbGUubmV0OnBhc3N3b3Jk