In the previous step, we have successfully implemented the first endpoint
of the RSS reader app.
The RSS reader example assumes implementing 3 endpoints. This article is dedicated to implementing the GET /user/{user_id}/rss_channels endpoint.
Before completing this step, make sure your are in the step_2 git branch:
Implementing the second endpoint
The second endpoint produces an array of RSS channels by given user_id.
We need to execute the two following queries to:
Fetch RSS links for a given user:
Fetch RSS channel details for a given link:
Implementation
The endpoint allows the the front-end app to display the list of RSS feeds a user subscribed on. When the endpoint is accessed, the AppVerticle#getRssChannels method is called. We can implement this method in this way:
Also, this method uses selectChannelInfo and selectRssLinksByLogin fields, they should be initialized in the AppVerticle#prepareNecessaryQueries method:
Conclusion
In this part, we have successfully implemented the second endpoint, which allows the browser app to obtain channels information for a specific user. To ensure that it is working fine, point your browser to localhost:8080 and click to the refresh button. Channel list should appear immediately.
If you have any problems with completing this step you can checkout to step_3, where you can find all changes made for completing this step:
Thanks for reading this. I hope you enjoyed reading this article. See you soon on our Gitter channel!