知识卡片
路由条件共同限定资源操作
路径变量让同一路由处理多个键,方法、主机或协议等匹配条件进一步限定允许的请求。REST设计把键值对视为资源,GET读取、PUT设置、DELETE删除。端点路径必须在文档、注册和测试中保持一致;本原稿的/v1/key/{key}与/v1/{key}不一致,不能照抄成一份接口契约。
原稿路由形式:r.HandleFunc("/v1/{key}", keyValuePutHandler).Methods("PUT"),这里只展示匹配语法,须先统一正式路径。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- Building a Cloud Native Service · 查看原书依据
The URI for our key-value pair resources will have the form /v1/key/{key}, where {key} is the unique key string. The v1 segment indicates the API version. This is convention is often used to manage API changes, and while this practice is by no means required or universal, it can be helpful for managing the impact
参考来源
- 位置:《Cloud Native Go》第05章《Building a Cloud Native Service》(来源项目book-sources;源文件:extracted/Cloud Native Go (Matthew A. Titmus)/_epub-src/OEBPS/ch05.xhtml)
- 结论依据:路径变量让同一路由处理多个键,方法、主机或协议等匹配条件进一步限定允许的请求。原文相应定义、示例或限制为此结论提供依据;补充纠错与版本边界在正文就近标明。
- 原始内容:The URI for our key-value pair resources will have the form /v1/key/{key}, where {key} is the unique key string. The v1 segment indicates the API version. This is convention is often used to manage API changes, and while this practice is by no means required or universal, it can be helpful for managing the impact