知识卡片
用词汇契约识别动作
语义profile是一份数据名与动作名的共享词汇。客户端预先理解id/body/doAdd/goList/doRemove等业务含义,再由消息提供URL、方法、编码和输入模板,便能使用不同位置的兼容服务。
ALPS可描述词汇、动作及返回目标;机器脚本例如REQUEST WITH-FORM doAdd WITH-STACK按动作名操作。在ALPS中,数据描述项用type:"semantic",动作可标safe/unsafe/idempotent,rt指向预期返回状态,动作的嵌套descriptor声明输入。这些元数据可帮助客户端判断怎样提交和期待何种结果,不应把unsafe动作当作可随意重放。
只有媒体类型相同还不够:格式告诉客户端怎样读,profile告诉它读到的名字意味着什么。没有服务词汇文档时,可依据API文档整理团队自用版本,但要承担维护成本。
关联:[[客户端绑定消息结构]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 超媒体客户端 · 查看原书依据
To make sure clients and servers are “talking the same language” at runtime, you should make sure both client and server are coded to understand the same vocabulary terms (e.g., data names and action names). You can accomplish this by relying on one of the well-known vocabulary formats, including:
参考来源
- 位置:《RESTful Web API Patterns and Practices Cookbook》第4章《Hypermedia Clients》(来源项目book-sources:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch04.xhtml,配方4.4)
- 结论依据:原文用ToDo词汇、ALPS descriptor与HyperLANG动作调用,说明共享语义如何独立于具体服务位置。
- 原始内容:To make sure clients and servers are “talking the same language” at runtime, you should make sure both client and server are coded to understand the same vocabulary terms (e.g., data names and action names). You can accomplish this by relying on one of the well-known vocabulary formats, including: