简体   繁体   English

根据REST中的资源在PUT操作的URL中提供ID和资源

[英]Providing IDs and resources in the URLs of PUT operation based on the resources in REST

Our System contains many documents, and each document can have 3 states say A , B and C. 我们的系统包含许多文档,每个文档可以有3个状态,分别是A,B和C。

/doc/{docId}/A - POST operation creates a doc with state A and also generates a new Id for state A. / doc / {docId} / A -POST操作会创建状态为A的文档,还会为状态A生成新的ID。

Now this state A can be converted to state B or state C. Now to define this, URLs created are like /doc/{docId}/A/{aId}/B - PUT operation will create new B from A. 现在可以将状态A转换为状态B或状态C。现在要定义它,创建的URL类似于/ doc / {docId} / A / {aId} / B -PUT操作将从A创建新的B。

/doc/{docId}/A/{aId}/C - PUT operation will create new C from A / doc / {docId} / A / {aId} / C -PUT操作将从A创建新的C

Similary , State B can be converted to state C and vice versa. 类似地,状态B可以转换为状态C,反之亦然。 To be complete Rest oriented we dont want to use RPC and so dont want to provide identification of state B or C in XML request. 为了完整的面向休息,我们不想使用RPC,因此也不想在XML请求中提供状态B或C的标识。

So please let me know if there is a better way of achieving this. 因此,请告诉我是否有更好的方法来实现这一目标。

It seems you are overloading the URI with state. 看来您正在用状态超载URI。 If it's a single resource with three states, then it should have a single URI, and PUT should be used to change the state (using the PUT payload). 如果它是具有三个状态的单个资源,则它应该具有一个URI,并且应该使用PUT更改状态(使用PUT有效负载)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM