I have a system where logged in users can vote like or dislike on posts. If they try to like a post which has already been liked, they ll remove its vote. Same applies for dislike. As a REST newbie I am trying to come up with a url scheme for this and it is confusing
Currently, my urls look like this
POST /news/vote/social/:feedItemId/:vote(like|dislike|reset)
A single endpoint is doing everything and logged in users are the ones who can actually vote
After reading some other answers on stackoverflow it seems there are other possibilities as well like
PUT /news/vote/social/:feedItemId/(like|dislike)
DELETE /news/vote/social/:feedItemId
I have seen other answers where the userId is also included in the url because it says REST API design should not reflect statefulness
PUT /news/vote/social/feedItemId/:userId/(like|dislike)
DELETE /news/vote/social/:userId/:feedItemId
The problem with these urls is any person can update any userId s vote unless some backend check is involved
My question, is what is the right way to handle these considering only logged in people should be able to update only their vote?