RESTful URLs for Selected Resource Versions

I have a real hard time conceptually understanding something right about URLs for versions with versions.

Let's say I have an application that tracks recipes in a way very similar to a version control system, for example, in an old school such as RCS or something like that. Each version can be a working copy for some time, and then create a new version. Each version has comments associated with it and does not transmit comments. I can return historically at any time and look at the recipe as it develops, but each instance is always considered a version of the same recipe. I am trying to find the most suitable way to create URLs to link to them, and I am having trouble understanding some of the differences between similar sub-resources and temporary resources, etc.

The two main ways I've seen are:

> 1) query parameters
> -- /recipes/ultimate-thing                -> List of available versions of Ultimate Thing
> -- /recipes/ultimate-thing?version=2      -> Version 2 of Ultimate Thing
> -- /recipes/ultimate-thing?version=latest -> Current working version of Ultimate Thing

2a) Nested resources with versions considered subresources
-- /recipes/ultimate-thing/versions/      -> List of available versions of Ultimate Thing
-- /recipes/ultimate-thing/versions/2     -> Version 2 of Ultimate Thing
-- /recipes/ultimate-thing                -> Current working version of Ultimate Thing

2b) Nested resources with the list at the resource
-- /recipes/ultimate-thing                 -> List of available versions of Ultimate Thing
-- /recipes/ultimate-thing/versions/2      -> Version 2 of Ultimate Thing
-- /recipes/ultimate-thing/versions/latest -> Current working version of Ultimate Thing

, , , , , .

1 , , , POST (/recipes/ultimate-thing) , , - 404 /recipes, , POSTs /recipes/ultimate-thing ? , ? - /recipes/ultimate-thing/comments, /recipes/utlimate-thing/comments? Version = latest , 2b " ", 2a .

, 2, , , , , .

2b , stackoverflow, , , - /recipes/ultimate-thing/version/latest/comments. , , , , .

2a, - , , ? - , 1 , , ?

- /recipes/ultimate-thing/latest /recipes/ultimate-thing/2/comments, , ?

, - , , , .

+5
3

. . , REST , , . , , .

: # 1: /recipes/cake? version = 2

. Google , URI. , URI.

2 3, -, REST, -. , /recipes/cake/2 "cake" 2./ recipes/cake/version/2 "" -, .

+4

2a 2b:

2c) Nested resources with versions considered subsets
-- /recipes/ultimate-thing/versions/      -> List of available versions of Ultimate Thing
-- /recipes/ultimate-thing/versions/2     -> Version 2 of Ultimate Thing
-- /recipes/ultimate-thing/versions/latest-> Redirect to current working version of Ultimate Thing

URI "" "", URI . URI , , HTTP URI , URI . : . "" "" - : . "" - "", , , .

, recipes/cherry-pie/ , , . , , versions/, , - . URI recipes/cherry-pie/versions/ , ; , , URI recipes/cherry-pie/versions/{version}/. versions/ recipes/cherry-pie/versions/latest/, recipes/cherry-pie/versions/182/ .

. , , , . , . ; ( ); , , , , ​​ ; . , , , - ( , recipes/byname/pie/quickview), ).

+3

It all depends on how you look at the version of resources. Whether they will simply be used for historical tracking, as in the wiki, or versions are separate resources. In the first case, the EJK answer seems like a good solution. For the second case, creating a new unique identifier for resource versions / options may be another solution. For instance:

3) Resources with versions
-- /recipes/                          -> List of available recipes versions
-- /recipes/ultimate-thing-version-2  -> Version 2 of Ultimate Thing
-- /recipes/ultimate-thing            -> The "offical" version of Ultimate Thing

This is an even more preferable solution if the resources are variations of each other:

3) List of recipes
-- /recipes/                           -> List of available recipes and variations
-- /recipes/ultimate-thing-with-sugar  -> The Ultimate Thing recipe with sugar
-- /recipes/ultimate-thing-with-honey  -> The Ultimate Thing recipe with honey
0
source

All Articles