Created
June 21, 2011 14:06
-
-
Save thibaudgg/1037932 to your computer and use it in GitHub Desktop.
Custom Goliath Rack middleware for HoptoadNotifier
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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!