Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 31 lines (22 sloc) 0.904 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
require 'sinatra'
require(File.join(File.dirname(__FILE__), '..', 'lib', 'rack-superfeedr.rb'))


use Rack::Superfeedr, { :host => "pstx.showoff.io", :login => "demo", :password => "demo", :format => "json", :async => false } do |superfeedr|
  set :superfeedr, superfeedr # so that we can use `settings.superfeedr` to access the superfeedr object in our application.

  superfeedr.on_notification do |notification|
    puts notification.to_s # You probably want to persist that data in some kind of data store...
  end

end

get '/hi' do
  "Hello World!" # Maybe serve the data you saved from Superfeedr's handler.
end

get '/subscribe' do
  subscription = settings.superfeedr.subscribe("http://push-pub.appspot.com/feed")
  if !subscription
    settings.superfeedr.error
  else
    'Subscribed'
  end
end

get '/unsubscribe' do
  settings.superfeedr.unsubscribe("http://push-pub.appspot.com/feed")
end

Something went wrong with that request. Please try again.