知识卡片

问题卡 · 5025.b

本地补充链接与表单

理解等级:中级

服务不返回超媒体控制时,客户端仍可通过本地动作元数据复用统一执行引擎。

服务只返回数据时,可从API文档抽取链接及表单元数据,集中存放href/method/args/required/pattern等信息,交给同一个超媒体渲染及调用引擎。

例如编辑动作配置href:"/user/{id}", method:"PUT"并列出可编辑字段。若不同角色允许的动作不同,应分别维护动作集合。这样可复用客户端执行逻辑,但元数据仍是静态复制,服务变更后需要同步;不会获得真正由服务实时下发控制的更新保证。

关联:[[按超媒体控制发请求]]。

这张卡片看不懂?

已有反馈 · 0 / 10 条

    还没有人提交反馈。

    在整书笔记中的位置

    原书出处 · 1 处

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

      When you’re working with services that don’t offer hypermedia-style responses and you still want to be able to rely on clearly described links and forms on the client side, you can code your client application to supply its own links and forms at runtime, based on the original API documentation.

    参考来源

    - 位置:《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.10) - 结论依据:原文把人工API文档转换成g.actions对象,保留地址、方法、参数与规则,并讨论角色和版本同步。 - 原始内容:When you’re working with services that don’t offer hypermedia-style responses and you still want to be able to rely on clearly described links and forms on the client side, you can code your client application to supply its own links and forms at runtime, based on the original API documentation.