Skip to content

Instantly share code, notes, and snippets.

@thibaudgg
Created June 21, 2011 14:06
Show Gist options
  • Select an option

  • Save thibaudgg/1037932 to your computer and use it in GitHub Desktop.

Select an option

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

endel commented Sep 8, 2011

Copy link
Copy Markdown

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
Copy Markdown
Author

Thanks for that one!

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