Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/kotlin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
什么是RESTful创建节点树的合适URI方案?_Rest_Tree - Fatal编程技术网

什么是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资源:

  • GEThttp://example.com/product_instances/new
    -HTML表单
  • POSThttp://example.com/product_instances
    -创建新资源
  • GEThttp://example.com/product_instances/1/children/new
    -HTML表单
  • POSThttp://example.com/product_instances/1/children
    -创建新资源,其父对象是product\u实例1
我想到的另一个方案是提供参数并重新使用“普通的新建和创建”:

  • GEThttp://example.com/product_instances/new
    -HTML表单
  • POSThttp://example.com/product_instances
    -创建新资源
  • GEThttp://example.com/product_instances/new?parent=1
    -HTML表单
  • POSThttp://example.com/product_instances/
    -在有效负载中包括父项=1
这种模式有什么标准吗?是否有一些规则或指南可以解释如何处理RESTful URI模式中的树型项

注意:我只关注new和create,因为我想说,对于有父项和没有父项的项目,
显示、更新/编辑和删除
没有什么不同,因为它们作用于已存储的
产品实例
,因此父项是已知的,不需要在URI或有效负载中提供