What's a RESTful way to query with logic operation?

夙愿已清 提交于 2019-12-05 17:42:28

Depending on the exact requirements, I would perhaps start with the "google" approach. Just present a query form, and create some primitive query language which might be just text (it's not necessary to use json if it's simple enough).

So the search page would look something like this:

{ "searchForm": {
    "target": "/workloads",
    "method": "GET",
    "components": [{ "name": "q" }]
  }
}

The media-type for the search page would define how to use the form, probably that it should make a request like:

GET /workloads?q=+A+B-C

For the query language I would go for the absolute minimum. Maybe just "+" and "-" signs, just like google. I would probably stay with a text query language even when more complex queries are needed, just to make it easy to read/test manually.

Or, if you don't want to be that RESTful, you can hardcode the query-uri into the application, that way you don't have to create the search page its media-type.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!