Does magic (me / self) use resource identifiers that go against the principles of REST?

I saw URIs that support magic identifiers for an authenticated user, as shown below:

GET /user/me - list my profile
GET /user/me/photos - list my photos

where the ones below use the actual user id

GET /user/742924
GET /user/742924/photos

The problem that I see is that the same resource identifier points to a different resource depending on the authenticated user.

Is this against any REST principles?

+9
source share
3 answers

/me , , REST. , , , :

5.2.1.1

REST - . , , : , (, " -" ), , (, ) .., , , , . , , . [...]

/me , , , .

+13

, , , :

REST : . , , , , -, , . REST , , , , . , , , , .

, - .

+3

.

, , , URI. " " "user 742924", .

It can be even worse than “current user”, “last registered user”, “user with a name starting with A”, “oldest user”, etc. All of these can be different resources, even if they can point to the same "user".

+1
source

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


All Articles