roda 3.57.0 → 3.58.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +8 -0
- data/doc/release_notes/3.58.0.txt +16 -0
- data/lib/roda/plugins/exception_page.rb +20 -4
- data/lib/roda/plugins/filter_common_logger.rb +46 -0
- data/lib/roda/plugins/heartbeat.rb +5 -10
- data/lib/roda/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01acdb87d6bf21ec4137dd2b6c7e3210c5923c43f188a510135c30a66945160a
|
4
|
+
data.tar.gz: e84ddddfbfe23a4be3951c2611f38916cb6dfb60b15c1a6bfd18155869ad4985
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1681a1b8b8eb950be113d1a533c545ed0a71c24dc6d027a41d2cddb1ae99e4a2c2d23fc0e4c84d1f2960fd141021684d37d75e8509b247d732203100eae6ab2f
|
7
|
+
data.tar.gz: a21456321d0ab6f3c32d4ba97dabd31635751caee7889a2b556dd17cc74fb019d974cc06500081a859402cbf8002a26144d4885dbd8c47589852395d1e398ed2
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
= 3.58.0 (2022-07-13)
|
2
|
+
|
3
|
+
* Add filter_common_logger plugin for skipping the logging of certain requests when using the common_logger plugin (jeremyevans)
|
4
|
+
|
5
|
+
* Make exception_page plugin use Exception#detailed_message on Ruby 3.2+ (jeremyevans)
|
6
|
+
|
7
|
+
* Make heartbeat plugin compatible with recent changes in the rack master branch (jeremyevans)
|
8
|
+
|
1
9
|
= 3.57.0 (2022-06-14)
|
2
10
|
|
3
11
|
* Make static_routing plugin depend on the hash_paths instead of the hash_routes plugin (jeremyevans)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* A filter_common_logger plugin has been added, allowing you to skip
|
4
|
+
logging of certain requests in the common_logger plugin. This
|
5
|
+
allows you to only log requests for certain paths, or only log
|
6
|
+
requests for certain types of responses.
|
7
|
+
|
8
|
+
= Other Improvements
|
9
|
+
|
10
|
+
* The heartbeat plugin is now compatible with recent changes in the
|
11
|
+
rack master branch (what will be rack 3).
|
12
|
+
|
13
|
+
* The exception_page plugin will now use Exception#detailed_message
|
14
|
+
on Ruby 3.2+, preserving the did_you_mean and error_highlight
|
15
|
+
information. Additionally, the display of exception messages
|
16
|
+
has been improved.
|
@@ -127,7 +127,7 @@ div.context ol.context-line li span { float: right; }
|
|
127
127
|
div.commands { margin-left: 40px; }
|
128
128
|
div.commands a { color:black; text-decoration:none; }
|
129
129
|
#summary { background: #ffc; }
|
130
|
-
#summary h2 { font-weight: normal; color: #666; }
|
130
|
+
#summary h2 { font-weight: normal; color: #666; font-family: monospace; white-space: pre-wrap;}
|
131
131
|
#summary ul#quicklinks { list-style-type: none; margin-bottom: 2em; }
|
132
132
|
#summary ul#quicklinks li { float: left; padding: 0 1em; }
|
133
133
|
#summary ul#quicklinks>li+li { border-left: 1px #666 solid; }
|
@@ -196,12 +196,13 @@ END
|
|
196
196
|
# Designed to be used with the +json+ exception, which will
|
197
197
|
# automatically convert the hash to JSON format.
|
198
198
|
def exception_page(exception, opts=OPTS)
|
199
|
+
message = exception_page_exception_message(exception)
|
199
200
|
if opts[:json]
|
200
201
|
@_response['Content-Type'] = "application/json"
|
201
202
|
{
|
202
203
|
"exception"=>{
|
203
204
|
"class"=>exception.class.to_s,
|
204
|
-
"message"=>
|
205
|
+
"message"=>message,
|
205
206
|
"backtrace"=>exception.backtrace.map(&:to_s)
|
206
207
|
}
|
207
208
|
}
|
@@ -319,7 +320,7 @@ END
|
|
319
320
|
|
320
321
|
<div id="summary">
|
321
322
|
<h1>#{h exception.class} at #{h r.path}</h1>
|
322
|
-
<h2>#{h
|
323
|
+
<h2>#{h message}</h2>
|
323
324
|
<table><tr>
|
324
325
|
<th>Ruby</th>
|
325
326
|
<td>
|
@@ -394,7 +395,22 @@ END1
|
|
394
395
|
END
|
395
396
|
else
|
396
397
|
@_response['Content-Type'] = "text/plain"
|
397
|
-
"#{exception.class}: #{
|
398
|
+
"#{exception.class}: #{message}\n#{exception.backtrace.map{|l| "\t#{l}"}.join("\n")}"
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
private
|
403
|
+
|
404
|
+
# :nocov:
|
405
|
+
if RUBY_VERSION >= '3.2'
|
406
|
+
def exception_page_exception_message(exception)
|
407
|
+
exception.detailed_message(highlight: false).to_s
|
408
|
+
end
|
409
|
+
# :nocov:
|
410
|
+
else
|
411
|
+
# Return message to use for exception.
|
412
|
+
def exception_page_exception_message(exception)
|
413
|
+
exception.message.to_s
|
398
414
|
end
|
399
415
|
end
|
400
416
|
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
class Roda
|
5
|
+
module RodaPlugins
|
6
|
+
# The skip_common_logger plugin allows for skipping common_logger logging
|
7
|
+
# of some requests. You pass a block when loading the plugin, and the
|
8
|
+
# block will be called before logging each request. The block should return
|
9
|
+
# whether the request should be logged.
|
10
|
+
#
|
11
|
+
# Example:
|
12
|
+
#
|
13
|
+
# # Only log server errors
|
14
|
+
# plugin :filter_common_logger do |result|
|
15
|
+
# result[0] >= 500
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# # Don't log requests to certain paths
|
19
|
+
# plugin :filter_common_logger do |_|
|
20
|
+
# # Block is called in the same context as the route block
|
21
|
+
# !request.path.start_with?('/admin/')
|
22
|
+
# end
|
23
|
+
module FilterCommonLogger
|
24
|
+
def self.load_dependencies(app)
|
25
|
+
app.plugin :common_logger
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.configure(app, &block)
|
29
|
+
app.send(:define_method, :_common_log_request?, &block)
|
30
|
+
app.send(:private, :_common_log_request?)
|
31
|
+
app.send(:alias_method, :_common_log_request?, :_common_log_request?)
|
32
|
+
end
|
33
|
+
|
34
|
+
module InstanceMethods
|
35
|
+
private
|
36
|
+
|
37
|
+
# Log request/response information in common log format to logger.
|
38
|
+
def _roda_after_90__common_logger(result)
|
39
|
+
super if result && _common_log_request?(result)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
register_plugin(:filter_common_logger, FilterCommonLogger)
|
45
|
+
end
|
46
|
+
end
|
@@ -14,13 +14,6 @@ class Roda
|
|
14
14
|
#
|
15
15
|
# plugin :heartbeat, path: '/status'
|
16
16
|
module Heartbeat
|
17
|
-
# :nocov:
|
18
|
-
HEADER_CLASS = (defined?(Rack::Headers) && Rack::Headers.is_a?(Class)) ? Rack::Headers : Hash
|
19
|
-
# :nocov:
|
20
|
-
private_constant :HEADER_CLASS
|
21
|
-
|
22
|
-
HEARTBEAT_RESPONSE = [200, {'Content-Type'=>'text/plain'}.freeze, ['OK'.freeze].freeze].freeze
|
23
|
-
|
24
17
|
# Set the heartbeat path to the given path.
|
25
18
|
def self.configure(app, opts=OPTS)
|
26
19
|
app.opts[:heartbeat_path] = (opts[:path] || app.opts[:heartbeat_path] || "/heartbeat").dup.freeze
|
@@ -32,9 +25,11 @@ class Roda
|
|
32
25
|
# If the request is for a heartbeat path, return the heartbeat response.
|
33
26
|
def _roda_before_20__heartbeat
|
34
27
|
if env['PATH_INFO'] == opts[:heartbeat_path]
|
35
|
-
response =
|
36
|
-
response
|
37
|
-
|
28
|
+
response = @_response
|
29
|
+
response.status = 200
|
30
|
+
response['Content-Type'] = 'text/plain'
|
31
|
+
response.write 'OK'
|
32
|
+
throw :halt, response.finish
|
38
33
|
end
|
39
34
|
end
|
40
35
|
end
|
data/lib/roda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.58.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -229,6 +229,7 @@ extra_rdoc_files:
|
|
229
229
|
- doc/release_notes/3.55.0.txt
|
230
230
|
- doc/release_notes/3.56.0.txt
|
231
231
|
- doc/release_notes/3.57.0.txt
|
232
|
+
- doc/release_notes/3.58.0.txt
|
232
233
|
- doc/release_notes/3.6.0.txt
|
233
234
|
- doc/release_notes/3.7.0.txt
|
234
235
|
- doc/release_notes/3.8.0.txt
|
@@ -293,6 +294,7 @@ files:
|
|
293
294
|
- doc/release_notes/3.55.0.txt
|
294
295
|
- doc/release_notes/3.56.0.txt
|
295
296
|
- doc/release_notes/3.57.0.txt
|
297
|
+
- doc/release_notes/3.58.0.txt
|
296
298
|
- doc/release_notes/3.6.0.txt
|
297
299
|
- doc/release_notes/3.7.0.txt
|
298
300
|
- doc/release_notes/3.8.0.txt
|
@@ -336,6 +338,7 @@ files:
|
|
336
338
|
- lib/roda/plugins/error_handler.rb
|
337
339
|
- lib/roda/plugins/error_mail.rb
|
338
340
|
- lib/roda/plugins/exception_page.rb
|
341
|
+
- lib/roda/plugins/filter_common_logger.rb
|
339
342
|
- lib/roda/plugins/flash.rb
|
340
343
|
- lib/roda/plugins/h.rb
|
341
344
|
- lib/roda/plugins/halt.rb
|