I want to send my controller a website url and my server will fetch some details related to that site and send me back. Something similar to what this site does.

How do I go about modelling this problem in restful way?

I can create a WebsiteDetails controller and then should I do

GET /website_details?url=xyz.com

but it doesn't feel right as this should refer to an action that returns list of items. Any suggestion on this?

Write your answer…

@ankitsinghaniyaz, when I try to visit the link I get an error saying 'Security token doesn't match, possible CSRF attack.' So, I am not quite sure what your example does. To me, the problem statement sounds like a web crawler. If that's the case, why do you say that GET/website_details?url=xyz.com is not RESTful?

Going by specs, this is how a REST GET is defined:

The GET method requests transfer of a current selected representation for the target resource. GET is the primary mechanism of information retrieval

Show all replies

@ankitsinghaniyaz, Every object usually has two kind of GET routes - a getById route aka '/posts/:id' and a getS route aka '/posts'. Like @chilimatic says, you can use query parameters on a getS route and filter it according to what you need. It pretty much adheres to the REST specification.

Reply to this…