English 中文(简体)
处理数据库代码表时的基本REST设计?
原标题:Basic REST design when dealing with database code tables?
  • 时间:2012-05-26 13:49:38
  •  标签:
  • rest

我在REST上读过的东西 似乎他们总是在返回 REST 回复时 使用描述而非身份识别。 例如 :

<order>
    <orderstatus>
        open
     </orderstatus>
     .....
     .....
</order>

使用 ID 有问题吗? 例如, 如果“ 打开” 是 {1}, 则使用 ID 是否有问题?

<order>
     <orderstatus>
        1
     </orderstatus>
     .......
     ........
</order>

我想象你将有另一个代码表格的URL来获取描述。 例如 : http://basel/codables/orderstatus & amp; http://basell/codables/orderstatus/{id/code> 。

问题回答

一般来说, ID 只是为了让数据库保持正常化和提供独一性。 因此, 很少需要 REST API 来暴露 ID 。 因此, 您可能需要重新检查设计, 以确定为什么出现这种需要 。

也就是说,如果你的用法不同, 身份证实际上是 需要在外面的东西, 那么,我看不出有什么问题 REST APIs返回身份证。

资源状态在您在示例中显示的 XML 有效载荷中被描述或表达的程度完全相同。 使用打开的单词比第1 号更有利于人的眼睛, 因而不需要解释。 但我仍然不认为一个资源状态比另一个选择更适合“ REST ” 。 因为可以说即使打开的单词也应该得到很好的解释。 消费者应该能够理解开放状态的真正含义。 从那个角度, 可能的状态转变是什么? 等等。

Secondly http://baseurl/codetables/orderstatus/{id} or http://baseurl/codetables/orderstatus/open are not really different from REST URL point of view. But another point to consider is that do you really need to represent attribute references as REST resources? What is the benefit? Sounds like equivalent of schema definitions in the WSDL world to me.





相关问题
Allow RESTful DELETE method in asp.net mvc?

im currently setting up asp.net to accept DELETE http verb in the application. However, when i send "DELETE /posts/delete/1" i always get a 405 Method not allow error. I tried to take a look at ...

Most appropriate API for URL shortening service

I ve just finished an online service for shortening URLs (in php5 with Zend Framework); you can enter an URL and you get an short URL (like tinyurl and such sites). I m thinking about the API for ...

Use HTTPClient or HttpUrlConnection? [closed]

We re implementing a REST client on JRE 1.4. Seems two good options for a client REST framework are HttpClient and HttpUrlConnection. Is there a reason to use HttpClient over the JRE s ...

Why can t I find the truststore for an SSL handshake?

I m using the Spring RESTTemplate on the client side to make calls to a REST endpoint. The client in this case is a Spring app and Tomcat is the servlet container. I m running into issues making a ...

Which Http redirects status code to use?

friendfeed.com uses 302. bit.ly uses 301. I had decided to use 303. Do they behave differently in terms of support by browsers ?

Three Step Buyonline The RESTful way

We are re-developing our buyonline functionality and we are doing it the RESTful way. The process is a three step one and the customer is asked to enter data at each step. Let s say the three URL s ...