由 RESTful 接口公开的表示提供的链接可以是完全不透明的,而不会违反 REST 的任何约束。因此,我建议 REST 完全符合得墨忒耳法则。不要求链接在其 URL 中公开 URL 空间的结构。
例如,在面向对象的场景中,您可以将调用 abc 替换为 a.bc
在 RESTful 表示中,您可以创建以下内容:
<a>
<link href="bc"/>
</a>
而不是做
GET a
<a>
<link href="b"/>
</a>
GET b
<b>
<link href="c"/>
</b>
GET c
我不得不不同意 altCognito 并说 REST 的主要目标之一是松散耦合。统一的接口、标准的媒体类型和 HATEOAS 都结合在一起产生了一个极其松散耦合的接口。
回应大卫的评论:
REST is all about super-loose coupling to the point where it is pointless for the provider to try to anticipate all the needs of the clients
Actually, REST is about limiting the clients options by providing only valid links in the representations. Within those constraints the client can attempt to satisfy its own needs. It is by removing the knowledge from the client of when certain requests can be made that you achieve loose coupling. Loose coupling is not achieved by listing a set of resources and saying "ok, you can GET, PUT, POST, DELETE all you want."