I am facing an issue with selecting the correct route for managing food photos in my application. I have records of food items along with their associated images. To retrieve all the images of a specific food item, I utilize the following endpoint:
GET /food/{id}/images
For uploading a new image to a particular food item, I employ this command:
POST /food/{id}/images
The challenge arises when I attempt to remove a photo. Since users can submit multiple images for the same food item, I cannot simply use:
DELETE /food/{id}/images
I have two potential solutions for this dilemma:
DELETE /food/{food_id}/images/{image_id}
DELETE /images/{id}
The first option maintains consistency with my photo retrieval structure but introduces redundancy since each image holds a unique identifier, making the food ID unnecessary. The second option appears cleaner, yet it lacks uniformity since image creation uses the /food/ prefix while deletion does not. Which routing strategy do you recommend?