REST架构的主要元素分为三类,分别是Data Element、Connector、Component。以下是三种元素中主要术语所对应的网络现实模型中的对象。
核心概念:
Resource:
The resource is not the storage object. The resource is not a mechanism that the server uses to handle the storage object. The resource is a conceptual mapping — the server receives the identifier (which identifies the mapping) and applies it to its current mapping implementation (usually a combination of collection-specific deep tree traversal and/or hash tables) to find the currently responsible handler implementation and the handler implementation then selects the appropriate action + response based on the request content. All of these implementation-specific issues are hidden behind the Web interface; their nature cannot be assumed by a client that only has access through the Web interface.
批注:资源的概念在REST里是最核心的,从作者针对基于网络的软件体系架构(Network-based Software Architecture)的角度出发,一切交互和操作都是面向资源的。Server端架构的一个核心理念就是资源的管理。Client端和Server端交互的对象就是资源的具体表现(Representation)。原则上,资源在REST架构中是静态的,Server端开发者在架构的时候就对一个服务中的所有资源进行了定义,这个定义是不轻易改变的。实质上资源就是人对现实中的一个概念实体的心理投射,例如说到汽车,人自然就会想到所对应的现实实体,这一映射关系是不会轻易改变的。因此一个资源的唯一标识URI一旦定义好之后,也是不会轻易改变的,可变的是隐藏在这个统一接口背后的实现及其所映射的实体(Representation)。