How to structure REST resource hierarchy?

前端 未结 2 560
予麋鹿
予麋鹿 2021-02-01 06:01

I\'m new to server side web development and recently I\'ve been reading a lot about implementing RESTful API\'s. One aspect of REST API\'s that I\'m still stuck on is how to go

2条回答
  •  离开以前
    2021-02-01 06:08

    The goal is to build convenient resource identifiers, don't try to cross-reference everything. You don't have to repeat your database relations in URL representation :)

    Links like /product/{id}/buyer should never exist, because there already is identifier for that resource: /user/{id}

    Although it's ok to have /product/{id}/buyers-list because list of buyers is a property of product that does not exist in other contexts.

提交回复
热议问题