REST GET verb with parameters

后端 未结 2 456
眼角桃花
眼角桃花 2021-02-06 01:00

I\'m sitting reading on some REST with my fellow teammates, we are writing a RoR application that is going to expose some of its functionality to the rest of the world.

相关标签:
2条回答
  • 2021-02-06 01:44

    Parameters are perfectly OK, especially for search-resources like in your case (querying a set of journals).

    I recently answered similar question (path vs. parameter)

    0 讨论(0)
  • 2021-02-06 01:52

    REST doesn't make query parameter "illegal" in any way. It's an architectural style, mainly about driving the application by exchanging representations. Considering URIs are meant to be opaque, there's no real difference between http://example.com/page/1 and http://example/?page=1 for example, as far as REST is concerned (it ultimately depends on the representations that are sent, but the choice or URI style tends to be an implementation detail).

    What matters is how the client are going to find out about the URIs of your reports. HTML can do this very well with forms and query parameters. Whether your service is for browser consumption or another agent doesn't really matter, you can use the same principles. You could have HTML forms (or equivalent if your client isn't a browser) if you want it to be more flexible or via explicit links on your top page. (You may find it's easier to split the range into two parameters, like "from" and "to", if you want this to be more dynamic.)

    0 讨论(0)
提交回复
热议问题