假设我正在创建一个RESTful服务来处理我在网上的仓库订单.
鉴于这些要求.我最初的想法是以这种方式设计端点.
# to request a new customer account
/customers/request {POST}
# create and view customers - limited to admins
/customers {GET, POST}
# view customer info, update a customer
/customers/{customer_id} {GET, PATCH}
# create and view orders for a customer
/customers/{customer_id}/orders {GET, POST}
# view and update order for a customer
/customers/{customer_id}/orders/{order_id} {GET, PATCH}
Run Code Online (Sandbox Code Playgroud)
我非常自信这些道路是有意义的,并遵循一般的宁静想法.但是,我不确定如何处理用户端点.问题是,我希望客户管理员能够创建可以使用其客户帐户创建订单的用户.客户管理员在哪里发布POST以实现此目的?我有几个想法.在这个答案之后,我想到了这一点.
# creation of users always done through this endpoint no matter what the
# authenticated user's …Run Code Online (Sandbox Code Playgroud)