本文介绍了使用过滤器进行查询的RESTful方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

说我的应用程序正在管理带有以下字段的称为工作负载的对象.我想为用户提供一个REST接口,以便用户通过标签查询工作负载.

Say my application is managing objects called workload, with the following fields. I want to expose a REST interface for user to query workloads by labels.

"Workload": {"id":"test1", "labels":["A", "B", "C"]}
"Workload": {"id":"test2", "labels":["A", "C", "D"]}
"Workload": {"id":"test3", "labels":["A", "B", "D"]}

No clue how to do this sort of rest api at all, other than ask user to query by A, B, C separately then do proper set operations themselves?

第二个查询是被跟踪为另一个问题

推荐答案

使用查询参数,很好重复它们.

GET /workloads?label=A&label=B&label=C

在简单的情况下,您也可以ornot这样的术语.

For simple cases you could alsoor and not the terms like this.

GET /workloads?or_label=A&or_label=B&label_not=C

这篇关于使用过滤器进行查询的RESTful方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-09 03:05
查看更多