Skip to content

Instantly share code, notes, and snippets.

@thibaudgg
Created June 21, 2011 14:06
Show Gist options
  • Save thibaudgg/1037932 to your computer and use it in GitHub Desktop.
Save thibaudgg/1037932 to your computer and use it in GitHub Desktop.
Custom Goliath Rack middleware for HoptoadNotifier
module Goliath
module Rack
class Hoptoad
include Goliath::Constants
def initialize(app)
@app = app
end
def call(env)
response = @app.call(env)
if env[RACK_EXCEPTION]
HoptoadNotifier.notify(env[RACK_EXCEPTION])
end
response
rescue Exception => e
HoptoadNotifier.notify(e)
end
end
end
end
require 'goliath'
require 'hoptoad_notifier'
HoptoadNotifier.configure do |config|
config.api_key = 'my_api_key'
end
require 'hoptoad' # custom middleware
class Server < Goliath::API
use Goliath::Rack::Hoptoad
def response(env)
raise 'Notify hoptoad'
[200, {}, "ouch"]
end
end
@endel
Copy link

endel commented Sep 8, 2011

I've tried to use it but it doesn't send notifications to the Airbrake server.
Check out my fork using Toadhopper and em-http-request: https://gist.github.com/1202597
Hope it helps someone!

@thibaudgg
Copy link
Author

Thanks for that one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment