Say I have a hypertext-based RESTful service that simulates an ice cream shop. To better manage my store, I want to be able to display the daily number of listings and the dollar value of each ice cream sold.
It seems that this reporting feature can be presented as a resource called DailyReport. DailyReport can be generated quickly, and there seems to be no advantage to actually storing reports on the server. I want only DailyReport for a few days, on other days I do not need to receive DailyReport. In addition, storing DailyReports on a server would make it difficult for customers who need to remember to delete reports that they no longer need.
The daily report is temporary; his presentation can be obtained only once. One way to do this would be to offer the "/ daily-reports", POST link, which will return a response containing the DailyReport view that lists the sales data for that day.
Edit: let it also say that I really want to make a POST request. DailyReport has many different options for creating a view, such as sorting the ice cream types alphabetically, by dollar value - or including hourly breakdowns - or optionally including the temperature for that day - or filtering out certain types of ice cream (as a list). Instead of using request parameters using GET, I would prefer the POST DailyReport view with the appropriate parameters (using a well-defined custom media type to document each option). The view I presented will display my parameters along with the report itself.
Is this the right way to think about a problem or use a different approach? If it is correct, what special considerations may be relevant when implementing the DailyReport resource? (For example, it would probably be impractical to set the Location header when returning after a POST request).
source
share