Good URI design for user resource login

I want to create a website that follows RESTful architecture. On my site, each user is identified by a permanent username and can manage their settings. For a settings resource, I am torn between two URI projects.

Option 1: / users / {username} / settings

Here is a generic settings resource URL pattern. Only a registered user can perform GET / PUT on their settings resource. However, this is quite complicated, as other user-specific resources should follow this example. It makes additive authentications that have access to all the settings of all users (or at least partially) easier.

Option 2: / my / settings

The URL of the settings resource for the current user. This is much simpler programming, but the URL does not indicate which resource it is. The '/ my' part becomes a kind of alias for '/ users / {username}'.

Almost all websites use a similar approach, as option 2. What do you guys think?

+3
source share
1 answer

Why not get along? Your / mine may simply be a redirect to / users / {myusername} / So you can use / my in the user interface, but your admin users can edit each user parameter via the / users / {username} controller

+2
source

Source: https://habr.com/ru/post/1772360/


All Articles