Rest架构风格详解
表现层状态转换(英语:Representational State Transfer,缩写:REST)是Roy Thomas Fielding博士于2000年在他的博士论文中提出来的一种万维网软件架构风格,目的是便于不同软件/程序在网络(例如互联网)中互相传递信息。
何为架构风格?
讲架构风格时,需要先讲讲设计模式、架构模式的定义。
设计模式
在《设计模式》这本书的「What is a Design Pattern?」小节,对设计模式下了一个明确的定义:
The design patterns in this book are descriptions of communicating objects and classes that are customized to solve a general design problem in a particular context.
设计模式描述了一组类和对象的关系,用以解决特定上下文内的某个常见的设计问题!
架构模式
那我们可以这么定义架构模式:架构模式描述了一组组件之间的关系,用以解决特定上下文内的某个常见的架构问题!
维基百科上也给架构模式做了类似的定义:
An architectural pattern is a general, reusable solution to a commonly occurring problem in software architecture within a given context
架构模式是一个通用的、可重用的解决方案,用以解决特定上下文内的某个常见的架构问题!
架构风格
Roy Thomas Fielding博士,在他的REST论文中,对架构风格做出了定义:
An architectural style is a coordinated set of architectural constraints that restricts the roles/features of architectural elements and the allowed relationships among those elements within any architecture that conforms to that style.
一种架构风格是一组协作的架