@@ -114,9 +114,26 @@ func (s *Server) setupRoutes() {
114114 {
115115 api .POST ("/auth/register" , userHandler .Register )
116116 api .POST ("/auth/login" , userHandler .Login )
117+
117118 api .GET ("/clubs" , clubHandler .GetAllClubs )
118119 api .GET ("/clubs/:id" , clubHandler .GetClub )
120+ api .GET ("/clubs/:id/members" , clubHandler .ListClubMembers )
119121 api .GET ("/clubs/:id/ratings" , clubHandler .ListClubRatings )
122+
123+ api .GET ("/posts/public" , postHandler .ListPublicPosts )
124+ api .GET ("/posts/popular" , postHandler .ListPopularPublicPosts )
125+
126+ api .GET ("/books" , bookHandler .ListBooks )
127+ api .GET ("/books/:id" , bookHandler .GetBookByID )
128+
129+ api .GET ("/posts/:id/likes" , postHandler .ListLikesByPostID )
130+ api .GET ("/posts" , postHandler .ListAllPosts )
131+ api .GET ("/posts/:id" , postHandler .GetPostByID )
132+
133+ api .GET ("/posts/:id/comments" , commentHandler .ListCommentsByPostID )
134+ api .GET ("/users/:id/comments" , commentHandler .ListCommentsByUserID )
135+ api .GET ("/comments/:id" , commentHandler .GetCommentByID )
136+ api .GET ("/comments/:id/likes" , commentHandler .ListLikesByCommentID )
120137 }
121138
122139 protected := api .Group ("/" )
@@ -135,8 +152,7 @@ func (s *Server) setupRoutes() {
135152 protected .POST ("/clubs/:id/join" , clubHandler .JoinClub )
136153 protected .POST ("/clubs/:id/leave" , middleware .RequireClubMembership (clubRepo ), clubHandler .LeaveClub )
137154 protected .POST ("/clubs/:id/ratings" , middleware .RequireClubMembership (clubRepo ), clubHandler .RateClub )
138-
139- protected .GET ("/clubs/:id/members" , clubHandler .ListClubMembers )
155+
140156 protected .PUT ("/clubs/:id/members/:user_id" , middleware .RequireClubMembershipWithRoles (clubRepo , "club_admin" , "moderator" ), clubHandler .UpdateClubMember )
141157 protected .GET ("/clubs/:id/members/:user_id" , clubHandler .GetClubMember )
142158
@@ -150,31 +166,22 @@ func (s *Server) setupRoutes() {
150166 protected .GET ("/events/:id/attendees" , middleware .RequireClubMembership (clubRepo ), eventHandler .GetEventAttendees )
151167
152168 protected .POST ("/books" , middleware .RestrictToRoles ("admin" , "superuser" ), bookHandler .CreateBook )
153- protected .GET ("/books/:id" , bookHandler .GetBookByID )
154169 protected .PUT ("/books/:id" , middleware .RestrictToRoles ("admin" , "superuser" ), bookHandler .UpdateBook )
155170 protected .DELETE ("/books/:id" , middleware .RestrictToRoles ("admin" , "superuser" ), bookHandler .DeleteBook )
156- protected .GET ("/books" , bookHandler .ListBooks )
157171
158172 protected .POST ("/posts" , middleware .RequireClubMembership (clubRepo ), postHandler .CreatePost )
159- protected .GET ("/posts/:id" , postHandler .GetPostByID )
160173 protected .PUT ("/posts/:id" , middleware .RequireClubMembership (clubRepo ), postHandler .UpdatePost )
161174 protected .DELETE ("/posts/:id" , middleware .RequireClubMembership (clubRepo ), postHandler .DeletePost )
162- protected .GET ("/posts" , postHandler .ListAllPosts )
163175
164176 protected .POST ("/posts/:id/like" , middleware .RequireClubMembership (clubRepo ), postHandler .LikePost )
165177 protected .POST ("/posts/:id/unlike" , middleware .RequireClubMembership (clubRepo ), postHandler .UnlikePost )
166- protected .GET ("/posts/:id/likes" , postHandler .ListLikesByPostID )
167178
168179 protected .POST ("/posts/:id/comments" , middleware .RequireClubMembership (clubRepo ), commentHandler .CreateComment )
169- protected .GET ("/comments/:id" , commentHandler .GetCommentByID )
170180 protected .PUT ("/comments/:id" , middleware .RequireClubMembership (clubRepo ), commentHandler .UpdateComment )
171181 protected .DELETE ("/comments/:id" , middleware .RequireClubMembership (clubRepo ), commentHandler .DeleteComment )
172- protected .GET ("/posts/:id/comments" , commentHandler .ListCommentsByPostID )
173- protected .GET ("/users/:id/comments" , commentHandler .ListCommentsByUserID )
174182
175183 protected .POST ("/comments/:id/like" , middleware .RequireClubMembership (clubRepo ), commentHandler .LikeComment )
176184 protected .POST ("/comments/:id/unlike" , middleware .RequireClubMembership (clubRepo ), commentHandler .UnlikeComment )
177- protected .GET ("/comments/:id/likes" , commentHandler .ListLikesByCommentID )
178185
179186 protected .POST ("/users/:id/reading/sync" , middleware .AuthorizeSelf (), readingHandler .SyncUserStats )
180187 protected .POST ("/users/:id/reading/start" , middleware .AuthorizeSelf (), readingHandler .StartReading )
0 commit comments