gpt4 book ai didi

RESTful 设计 : return an empty object as a template for create new form

转载 作者:行者123 更新时间:2023-12-01 07:46:24 25 4
gpt4 key购买 nike

我的问题很简单——我想。

目前存在以下 Uris:

http://someserver/service/item           GET   returns all items  
http://someserver/service/item POST creates a new item
http://someserver/service/item/{id} GET returns item with id {id}
http://someserver/service/item/{id} PUT updates item with {id}

我想要做的是返回一个空白的“项目”,就像一个用于创建新项目的模板,其中包含一个对象参数列表,它们的类型,是否需要。这样做的原因是我想构建一个完全不了解数据结构的通用 jquery 'create new' 插件,我可以将其应用于我所有的新对象。

实现这一点的最佳方法是什么?

我希望这是有道理的,并感谢您的时间。

最佳答案

我做几乎同样的事情。我在我的“项目列表”资源中包含了一个链接,您可以将其发布到。响应是新项目的模板。可以说,您也可以执行 GET 来检索模板,但我利用这个机会为该项目分配了一个新的 Id,因此我的请求不是幂等的。

关于RESTful 设计 : return an empty object as a template for create new form,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4932315/

25 4 0