知识卡片

问题卡 · 3481.c.1

运行时核对语义契约

理解等级:中级

客户端依赖某套业务词汇时,必须先确认目标服务实际返回了兼容词汇。

2022年书中描述的profile协商方案使用Accept-Profile请求期望词汇、Content-Profile声明实际词汇;也可从rel="profile"链接集合查找兼容标识。客户端必须检查返回值,不能把请求偏好当作服务承诺。

服务不支持目标profile时可返回406并列出可选项。该头字段方案在书中仍是草案和约定,适合双方明确协作的环境,不能当作所有HTTP服务的现行能力。profile尽量向后兼容,仅破坏兼容时换主标识,避免细碎版本增加运行负担。

关联:[[用词汇契约识别动作]]。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

    • 超媒体客户端 · 查看原书依据

      A client application can dependably check for semantic profile support in a service using the “profile negotiation” pattern. Clients can use the accept-profile request header to indicate the expected semantic profile, and services can use the content-profile response header to indicate the supporting semantic profile.

    参考来源

    - 位置:《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.5) - 结论依据:原文演示Accept-Profile、Content-Profile及406支持列表,并说明该协商在当时仍是草案。 - 原始内容:A client application can dependably check for semantic profile support in a service using the “profile negotiation” pattern. Clients can use the accept-profile request header to indicate the expected semantic profile, and services can use the content-profile response header to indicate the supporting semantic profile.