Jordan
Jordan

Reputation: 4628

Is it RESTful to recognize multiple identifiers of a resource?

What if http://example.com/foo and http://example.com/bar both represent the same resource and the server does not distinguish between the two? What if it uses them interchangeably within documents that form the engine of application state (following HATEOAS), so that it displays /bar in some contexts and /foo in others?

Is this RESTful?

One potential benefit of this is to attach descriptors to URIs, e.g. http://example.com/article/30204/The-Quick-Brown-Fox, for the sake of bookmarks, search engine queries, and in general the potential for people to recognize a URI just by looking at it.

Upvotes: 1

Views: 546

Answers (1)

Tom Howard
Tom Howard

Reputation: 6687

It is perfectly acceptable from a REST point of view for a resource to have multiple URIs, so long as those URIs are discovered by following hypermedia controls from the application's published entry point. However, I would recommend against doing so. Having multiple URIs means that some cache hits will now be misses and you can potentially confuse people as it will not be clear if the two URIs lead to the same resource or two different resources that are very similar.

Upvotes: 2

Related Questions