rss_controller.rb 516 B

123456789101112131415161718192021222324252627
  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. end
  18. render :json => { :items => items }
  19. end
  20. end