goalie 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/goalie.gemspec +2 -2
- data/lib/goalie/rails.rb +2 -2
- data/lib/goalie/version.rb +1 -1
- data/lib/goalie.rb +2 -10
- metadata +4 -4
data/goalie.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{goalie}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Helder Ribeiro"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-10-13}
|
13
13
|
s.description = %q{Middleware to catch exceptions and Rails Engine to render them. Error-handling views and controllers can be easily overriden.}
|
14
14
|
s.email = %q{helder@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
data/lib/goalie/rails.rb
CHANGED
@@ -2,8 +2,8 @@ module Goalie
|
|
2
2
|
class Engine < Rails::Engine
|
3
3
|
|
4
4
|
initializer "goalie.add_middleware" do |app|
|
5
|
-
app.middleware.
|
6
|
-
app.middleware.
|
5
|
+
app.middleware.insert_after 'ActionDispatch::RemoteIp', Goalie::CustomErrorPages
|
6
|
+
app.middleware.delete 'ActionDispatch::ShowExceptions'
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
data/lib/goalie/version.rb
CHANGED
data/lib/goalie.rb
CHANGED
@@ -8,7 +8,6 @@ module Goalie
|
|
8
8
|
# This middleware rescues any exception returned by the application
|
9
9
|
# and renders nice exception pages.
|
10
10
|
class CustomErrorPages
|
11
|
-
LOCALHOST = [/^127\.0\.0\.\d{1,3}$/, "::1", /^0:0:0:0:0:0:0:1(%.*)?$/].freeze
|
12
11
|
|
13
12
|
cattr_accessor :rescue_responses
|
14
13
|
@@rescue_responses = Hash.new(:internal_server_error)
|
@@ -62,7 +61,7 @@ module Goalie
|
|
62
61
|
log_error(exception)
|
63
62
|
|
64
63
|
request = ActionDispatch::Request.new(env)
|
65
|
-
if @consider_all_requests_local ||
|
64
|
+
if @consider_all_requests_local || request.local?
|
66
65
|
rescue_action_locally(request, exception)
|
67
66
|
else
|
68
67
|
rescue_action_in_public(request, exception)
|
@@ -106,19 +105,12 @@ module Goalie
|
|
106
105
|
:framework_trace => framework_trace(exception),
|
107
106
|
:full_trace => full_trace(exception)
|
108
107
|
}
|
109
|
-
request.env['
|
108
|
+
request.env['goalie.error_params'] = error_params
|
110
109
|
action = @@rescue_responses[exception.class.name]
|
111
110
|
response = PublicErrorsController.action(action).call(request.env).last
|
112
111
|
render(status_code(exception), response.body)
|
113
112
|
end
|
114
113
|
|
115
|
-
# True if the request came from localhost, 127.0.0.1.
|
116
|
-
def local_request?(request)
|
117
|
-
LOCALHOST.any? { |local_ip|
|
118
|
-
local_ip === request.remote_addr && local_ip === request.remote_ip
|
119
|
-
}
|
120
|
-
end
|
121
|
-
|
122
114
|
def status_code(exception)
|
123
115
|
Rack::Utils.status_code(@@rescue_responses[exception.class.name])
|
124
116
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: goalie
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 25
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 3
|
10
|
+
version: 0.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Helder Ribeiro
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-10-13 00:00:00 -03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|