知识卡片
用简单查询承载筛选
只需按若干字段筛选数据时,不必公开完整数据库查询语言。
简单查询可约定?name=value&city=value表示各字段“包含”条件的合取,既容易由表单生成,也不暴露底层SQL。=解释为包含是本接口约定,不能假定所有HTTP接口如此。
实现要定义空值、重复同名参数与大小写规则;例如空输入不应无意成为严格过滤。复杂查询语言塞入单一URL参数,可能触及长度、保留字符、编码、安全及模型耦合问题;需要更强语言时可用[[查询语言封装为媒体类型]]。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- 分布式数据 · 查看原书依据
Implementing your HTTP search support using name/value pairs with = operation supporting “contains” and the & supporting “AND” is the simplest IRQL you can implement for your HTTP APIs, and in my experience is often the only one you need. For more on URI query syntax, check out the related IETF specification.
参考来源
- 位置:《RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)》第6章《分布式数据》§6.4(来源项目:book-sources;源文件:extracted/RESTful Web API Patterns and Practices Cookbook Connecting and Orchestrating Microservices and Distributed Data (Mike Amundsen)/_epub-src/OEBPS/ch06.xhtml)
- 结论依据:原文以简单查询可约定`?name=value&city=value`表示各字段“包含”条件的合取,既容易由表单生成,也不暴露底层SQL的方式说明该用途;同节示例与讨论补充了卡内条件和边界。
- 原始内容:Implementing your HTTP search support using name/value pairs with = operation supporting “contains” and the & supporting “AND” is the simplest IRQL you can implement for your HTTP APIs, and in my experience is often the only one you need. For more on URI query syntax, check out the related IETF specification.