rss_controller.rb 529 B

12345678910111213141516171819202122232425262728
  1. class RssController < ApplicationController
  2. before_filter :authentication_check
  3. =begin
  4. Resource:
  5. GET /api/rss_fetch
  6. Response:
  7. {
  8. ...
  9. }
  10. Test:
  11. curl http://localhost/api/rss_fetch.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X GET
  12. =end
  13. def fetch
  14. items = RSS.fetch(params[:url], params[:limit])
  15. if items == nil
  16. render :json => { :message => "failed to fetch #{ params[:url] }", :status => :unprocessable_entity }
  17. return
  18. end
  19. render :json => { :items => items }
  20. end
  21. end