Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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

thibaudgg commented Sep 8, 2011

Thanks for that one!

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