前言 .................................................................................................................................... xx
开场:嗯,那是一次有趣的旅行,不是吗 .................................. xxviii
Bob、Carol 和BigCo 公司 ......................................................... xxx
第1 章 从HTML 到简单Web API .................................................1
任务处理系统(TPS)Web 应用 ...........................................................................4
来自服务器的HTML ......................................................................................5
将通用Web 浏览器作为客户端 ......................................................................9
评价 .................................................................................................................9
Task 服务Web API ...............................................................................................10
Web API 的常规实践 .....................................................................................10
设计TPS Web API......................................................................................... 11
实现TPS Web API.........................................................................................18
评价 ...............................................................................................................24
总结 .....................................................................................................................25
参考资料 ..............................................................................................................26
第2 章 JSON 客户端 ..................................................................29
JSON Web API 客户端 .........................................................................................30
Objects ..........................................................................................................31
Addresses ......................................................................................................34
Actions ..........................................................................................................35
小结 ...............................................................................................................38
JSON 单页面客户端.............................................................................................38
HTML 容器 ...................................................................................................38
顶层解析循环 ................................................................................................40
Objects、Addresses 和Actions .....................................................................41
小结 ...............................................................................................................47
应对变化 ..............................................................................................................47
添加字段和过滤器 ........................................................................................48
编写一个新客户端 ...............................................................................................52
总结 .....................................................................................................................54
参考资料 ..............................................................................................................57
第3 章 表述器模式 .....................................................................59
XML 还是JSON :选一个吧................................................................................62
新的分支:超媒体格式 .................................................................................63
“唯一正确”的谬误 ......................................................................................65
重建(reframe)问题 ....................................................................................66
表述器(Representor)模式 ................................................................................68
从功能中分离格式 ........................................................................................69
选择算法 .......................................................................................................69
适配和翻译 ...................................................................................................71
服务端模型 ..........................................................................................................74
处理HTTP Accept 头部参数 .........................................................................74
实现消息翻译器模式 .....................................................................................74
通用表述器模块 ............................................................................................76
WeSTL 格式 ..................................................................................................76
表述器的范例 ................................................................................................81
总结 .....................................................................................................................84
参考资料 ..............................................................................................................86
第4 章 HAL 客户端 .....................................................................89
HAL 格式 .............................................................................................................91
Links .............................................................................................................93
Objects 和Properties .....................................................................................94
内嵌Links 和Objects ....................................................................................95
小结 ...............................................................................................................97
HAL 表述器 .........................................................................................................97
Links .............................................................................................................98
Properties ......................................................................................................99
内嵌内容 ..................................................................................................... 100
HAL 表述器构建TPS 输出示例 .................................................................. 102
HAL SPA 客户端................................................................................................ 104
HTML 容器 ................................................................................................. 105
顶层解析循环 .............................................................................................. 106
Links ........................................................................................................... 107
内嵌内容 ..................................................................................................... 109
Properties .................................................................................................... 113
为HAL 处理Action .................................................................................... 114
小结 ............................................................................................................. 116
应对变化 ............................................................................................................ 117
添加ACTION ............................................................................................. 117
HAL-FORMS 扩展 ............................................................................................. 121
规范 ............................................................................................................. 121
请求HAL-FORMS 文档 .............................................................................. 123
实现 ............................................................................................................. 124
总结 ................................................................................................................... 125
参考资料 ............................................................................................................ 128
第5 章 可重用客户端应用的挑战 ...............................................131
你在解决什么问题 ............................................................................................. 133
设计的双钻石模型 ...................................................................................... 134
闭合方案 vs. 开放方案 ................................................................................ 134
交互建模 ............................................................................................................ 136
Maldonado 的机制 ....................................................................................... 137
Verplank 的人类视角 ................................................................................... 139
超媒体交互循环 ................................................................................................. 141
RPW 循环 .................................................................................................... 141
用代码实现RPW......................................................................................... 143
处理Verplank 的KNOW 步骤 .................................................................... 144
总结 ................................................................................................................... 148
参考资料 ............................................................................................................ 150
第6 章 Siren 客户端 .................................................................153
Siren 格式 .......................................................................................................... 155
Entities ........................................................................................................ 157
Class ............................................................................................................ 158
Properties .................................................................................................... 158
Links ........................................................................................................... 159
Actions ........................................................................................................ 159
SubEntities .................................................................................................. 160
小结 ............................................................................................................. 162
Siren 表述器 ....................................................................................................... 162
顶层循环 ..................................................................................................... 163
Class ............................................................................................................ 164
Properties .................................................................................................... 164
Entities ........................................................................................................ 165
Actions ........................................................................................................ 166
Links ........................................................................................................... 168
TPS 通过Siren 表述器输出示例 ................................................................. 169
Siren SPA 客户端 ............................................................................................... 172
HTML 容器 ................................................................................................. 173
顶层解析循环 .............................................................................................. 173
Links ........................................................................................................... 174
Entities ........................................................................................................ 176
Properties .................................................................................................... 178
Actions ........................................................................................................ 181
小结 ............................................................................................................. 184
应对变化 ............................................................................................................ 184
添加邮箱字段和过滤器 ............................................................................... 185
测试邮箱字段 .............................................................................................. 187
Profile 对象描述(POD)扩展 .......................................................................... 190
POD 规范 .................................................................................................... 191
实现 ............................................................................................................. 192
在Siren 中使用POD 展示对象 ................................................................... 194
小结 ............................................................................................................. 195
总结 ................................................................................................................... 196
参考资料 ............................................................................................................ 198
第7 章 版本化与Web ...............................................................199
互联网中的版本化 ............................................................................................. 201
TCP/IP 的健壮性原则 ................................................................................. 202
HTTP 中的MUST IGNORE ........................................................................ 203
HTML 的向后兼容性 .................................................................................. 205
非破坏性变更指南 ............................................................................................. 206
API 设计者 .................................................................................................. 206
服务端实现者 .............................................................................................. 209
客户端实现者 .............................................................................................. 215
总结 ................................................................................................................... 223
参考资料 ............................................................................................................ 225
第8 章 Collection+JSON 客户端 ...............................................227
Collection+JSON 格式 ....................................................................................... 229
Links ........................................................................................................... 232
Items ............................................................................................................ 233
Queries ........................................................................................................ 234
Template ...................................................................................................... 235
Error ............................................................................................................ 237
小结 ............................................................................................................. 237
Collection+JSON 表述器 ................................................................................... 238
顶层处理循环 .............................................................................................. 238
Links ........................................................................................................... 239
Items ............................................................................................................ 240
Queries ........................................................................................................ 243
Template ...................................................................................................... 244
Error ............................................................................................................ 245
Collection+JSON SPA 客户端 ............................................................................ 246
HTML 容器 ................................................................................................. 246
顶层解析循环 .............................................................................................. 248
Links ........................................................................................................... 249
Items ............................................................................................................ 250
Queries ........................................................................................................ 253
Template ...................................................................................................... 255
Error ............................................................................................................ 257
小结 ............................................................................................................. 258
处理变更 ............................................................................................................ 258
在TPS API 中添加Note 对象 ..................................................................... 259
Cj 和OAA 挑战 .......................................................................................... 265
小结 ............................................................................................................. 266
扩展Collection+JSON ....................................................................................... 266
用Cj-Types 支持改善的输入 ...................................................................... 267
Cj-Suggest 扩展 ........................................................................................... 271
小结 ............................................................................................................. 275
总结 ................................................................................................................... 275
参考资料 ............................................................................................................ 279
第9 章 超媒体与微服务 ...........................................................281
UNIX 哲学 ......................................................................................................... 284
BigCo 的TPS 微服务 ......................................................................................... 285
Task 服务与Collection + JSON ......................................................................... 286
User 服务与Siren ........................................................................................ 290
Note 服务与HAL ........................................................................................ 293
一个客户端,统领全局 ...................................................................................... 296
Home 服务................................................................................................... 297
多格式客户端SPA 容器 .............................................................................. 298
可以切换格式的客户端UI .......................................................................... 301
总结 ................................................................................................................... 308
参考资料 ............................................................................................................ 312
结语:拥抱你的未来 ..................................................................313
附录A 项目清单 ......................................................................315
附录B 工具与资源 ..................................................................319
· · · · · · (
收起)