Quantcast
Channel: Active questions tagged rest - Stack Overflow
Viewing all articles
Browse latest Browse all 3637

Mapping Actions to Rest URI

$
0
0

I have a resource 'Customer' for which I have REST endpoints defined as,

| URI                            | Function                            || ------------------------------ | ----------------------------------  || /apiv1/customers/              | {GET} Fetch all customers           || /apiv1/customers/{customer-id} | {GET} Fetch details of the customer || /apiv1/customers/              | {POST} Add a new customer           || /apiv1/customers/{customer-id} | {PUT} Update a customer             |

Now, I also have to design for some non CRUD operations like

  • Fetch top 5 customers by the amount paid
  • Fetch the last 3 customers
  • etc

How do I design URIs for actions like above?

My take on it has been to introduce a new controller with a separate endpoints for each function like:

  • /apiv1/customers/fetch-top-5
  • /apiv1/customers/fetch-last-3

I am still not feeling confident about the above approach. Also, what if I want to parameterize these actions like fetch-top-n customers


Viewing all articles
Browse latest Browse all 3637

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>