How to return random items RESTfully?

后端 未结 5 1536
有刺的猬
有刺的猬 2021-02-06 03:19

My design exposes two kinds of resources:

  1. Images
  2. Tags

I would like clients to be able to request random images by their tag(s). For example

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-06 03:36

    I agree with Triptych on this one. In a way adding random to the end of the URI makes it feel like an operation, but if it is scoped to a tag then you're really just refining the context.

    In his example of:

    /image/tagged/sometag/random

    images resource -> tagging scope (all images with tags) -> specific tag (all images with tag X) -> random (a resource from the scoped list of images with tag X)

提交回复
热议问题