I am studying REST API. I'm thinking about how to design the REST API for the following situations.
"If you click the Like button on a post, increase the number of likes on that post."
This corresponds to an UPDATE among CRUD. Right? Then should I express the URL like this?
POST /post/{post_id}/likes
But there also will be situations like this.
If you press the "Like" button again, Decrease the likes again.'
In that case, would it be appropriate to send a request with this data in the payload?
POST /post/{post_id}/likes
{
countup: False // decrease likes
}
I coudn't think of anything better than this,
but I feel strange that this isn't a very good idea.
I want to design the API to match the convention.
I'd appreciate it if you could give me some better ideas.