什么是RESTful创建节点树的合适URI方案?
我有一个什么是RESTful创建节点树的合适URI方案?,rest,tree,Rest,Tree,我有一个ProductInstance,它有零个或多个父对象,也有ProductInstances。它们是一棵树。例如: - ProductInstance VM - ProductInstance RAID - ProductInstance DISK - ProductInstance CPU 我希望我的URI方案能够创建这些,并且是干净和RESTful的。我应该如何设置 我提出的一个方案是嵌套URI资源: GEThttp://example.com/product_in
ProductInstance
,它有零个或多个父对象,也有ProductInstances
。它们是一棵树。例如:
- ProductInstance VM
- ProductInstance RAID
- ProductInstance DISK
- ProductInstance CPU
我希望我的URI方案能够创建这些,并且是干净和RESTful的。我应该如何设置
我提出的一个方案是嵌套URI资源:
-HTML表单GEThttp://example.com/product_instances/new
-创建新资源POSThttp://example.com/product_instances
-HTML表单GEThttp://example.com/product_instances/1/children/new
-创建新资源,其父对象是product\u实例1POSThttp://example.com/product_instances/1/children
-HTML表单GEThttp://example.com/product_instances/new
-创建新资源POSThttp://example.com/product_instances
-HTML表单GEThttp://example.com/product_instances/new?parent=1
-在有效负载中包括父项=1POSThttp://example.com/product_instances/
显示、更新/编辑和删除
没有什么不同,因为它们作用于已存储的产品实例
,因此父项是已知的,不需要在URI或有效负载中提供