RESTful URLs for distinct versions of a resource

前端 未结 4 2226
借酒劲吻你
借酒劲吻你 2021-02-14 13:29

I\'m having a real hard time conceptually understanding something proper concerning URLs for versioned resources.

Let\'s say I have an application that tracks recipes in

4条回答
  •  不要未来只要你来
    2021-02-14 14:20

    It all depends on how are you looking at the resource versions. Would these be just used for historical tracking like in wiki or the versions are separate resources. In the first case the EJK answer seems like a good solution. For the second case creating new unique identifier for the resource versions/variations could be another solution. For example:

    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 even more prefered 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
    

提交回复
热议问题