roda 3.83.0 → 3.84.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/roda/plugins/hsts.rb +35 -0
- data/lib/roda/response.rb +1 -1
- data/lib/roda/version.rb +1 -1
- metadata +4 -179
- data/CHANGELOG +0 -691
- data/README.rdoc +0 -1136
- data/doc/conventions.rdoc +0 -177
- data/doc/release_notes/3.0.0.txt +0 -84
- data/doc/release_notes/3.1.0.txt +0 -24
- data/doc/release_notes/3.10.0.txt +0 -132
- data/doc/release_notes/3.11.0.txt +0 -54
- data/doc/release_notes/3.12.0.txt +0 -19
- data/doc/release_notes/3.13.0.txt +0 -38
- data/doc/release_notes/3.14.0.txt +0 -36
- data/doc/release_notes/3.14.1.txt +0 -43
- data/doc/release_notes/3.15.0.txt +0 -21
- data/doc/release_notes/3.16.0.txt +0 -52
- data/doc/release_notes/3.17.0.txt +0 -62
- data/doc/release_notes/3.18.0.txt +0 -170
- data/doc/release_notes/3.19.0.txt +0 -229
- data/doc/release_notes/3.2.0.txt +0 -22
- data/doc/release_notes/3.20.0.txt +0 -7
- data/doc/release_notes/3.21.0.txt +0 -5
- data/doc/release_notes/3.22.0.txt +0 -24
- data/doc/release_notes/3.23.0.txt +0 -28
- data/doc/release_notes/3.24.0.txt +0 -14
- data/doc/release_notes/3.25.0.txt +0 -12
- data/doc/release_notes/3.26.0.txt +0 -15
- data/doc/release_notes/3.27.0.txt +0 -15
- data/doc/release_notes/3.28.0.txt +0 -13
- data/doc/release_notes/3.29.0.txt +0 -15
- data/doc/release_notes/3.3.0.txt +0 -291
- data/doc/release_notes/3.30.0.txt +0 -14
- data/doc/release_notes/3.31.0.txt +0 -11
- data/doc/release_notes/3.32.0.txt +0 -42
- data/doc/release_notes/3.33.0.txt +0 -8
- data/doc/release_notes/3.34.0.txt +0 -17
- data/doc/release_notes/3.35.0.txt +0 -12
- data/doc/release_notes/3.36.0.txt +0 -17
- data/doc/release_notes/3.37.0.txt +0 -42
- data/doc/release_notes/3.38.0.txt +0 -5
- data/doc/release_notes/3.39.0.txt +0 -16
- data/doc/release_notes/3.4.0.txt +0 -24
- data/doc/release_notes/3.40.0.txt +0 -24
- data/doc/release_notes/3.41.0.txt +0 -9
- data/doc/release_notes/3.42.0.txt +0 -21
- data/doc/release_notes/3.43.0.txt +0 -34
- data/doc/release_notes/3.44.0.txt +0 -23
- data/doc/release_notes/3.45.0.txt +0 -22
- data/doc/release_notes/3.46.0.txt +0 -19
- data/doc/release_notes/3.47.0.txt +0 -13
- data/doc/release_notes/3.48.0.txt +0 -10
- data/doc/release_notes/3.49.0.txt +0 -18
- data/doc/release_notes/3.5.0.txt +0 -31
- data/doc/release_notes/3.50.0.txt +0 -21
- data/doc/release_notes/3.51.0.txt +0 -20
- data/doc/release_notes/3.52.0.txt +0 -20
- data/doc/release_notes/3.53.0.txt +0 -14
- data/doc/release_notes/3.54.0.txt +0 -48
- data/doc/release_notes/3.55.0.txt +0 -12
- data/doc/release_notes/3.56.0.txt +0 -33
- data/doc/release_notes/3.57.0.txt +0 -34
- data/doc/release_notes/3.58.0.txt +0 -16
- data/doc/release_notes/3.59.0.txt +0 -17
- data/doc/release_notes/3.6.0.txt +0 -21
- data/doc/release_notes/3.60.0.txt +0 -56
- data/doc/release_notes/3.61.0.txt +0 -24
- data/doc/release_notes/3.62.0.txt +0 -41
- data/doc/release_notes/3.63.0.txt +0 -36
- data/doc/release_notes/3.64.0.txt +0 -26
- data/doc/release_notes/3.65.0.txt +0 -12
- data/doc/release_notes/3.66.0.txt +0 -23
- data/doc/release_notes/3.67.0.txt +0 -25
- data/doc/release_notes/3.68.0.txt +0 -21
- data/doc/release_notes/3.69.0.txt +0 -33
- data/doc/release_notes/3.7.0.txt +0 -123
- data/doc/release_notes/3.70.0.txt +0 -19
- data/doc/release_notes/3.71.0.txt +0 -33
- data/doc/release_notes/3.72.0.txt +0 -48
- data/doc/release_notes/3.73.0.txt +0 -33
- data/doc/release_notes/3.74.0.txt +0 -28
- data/doc/release_notes/3.75.0.txt +0 -19
- data/doc/release_notes/3.76.0.txt +0 -18
- data/doc/release_notes/3.77.0.txt +0 -8
- data/doc/release_notes/3.78.0.txt +0 -99
- data/doc/release_notes/3.79.0.txt +0 -148
- data/doc/release_notes/3.8.0.txt +0 -27
- data/doc/release_notes/3.80.0.txt +0 -31
- data/doc/release_notes/3.81.0.txt +0 -24
- data/doc/release_notes/3.82.0.txt +0 -43
- data/doc/release_notes/3.83.0.txt +0 -6
- data/doc/release_notes/3.9.0.txt +0 -67
@@ -1,52 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* A mail_processor plugin has been added for processing mail using
|
4
|
-
a routing tree. Quick example:
|
5
|
-
|
6
|
-
class MailProcessor < Roda
|
7
|
-
plugin :mail_processor
|
8
|
-
|
9
|
-
route do |r|
|
10
|
-
# Match based on the To header, extracting the ticket_id
|
11
|
-
r.to /ticket\+(\d+)@example.com/ do |ticket_id|
|
12
|
-
if ticket = Ticket[ticket_id.to_i]
|
13
|
-
# Mark the mail as handled if there is a valid ticket
|
14
|
-
# associated
|
15
|
-
r.handle do
|
16
|
-
ticket.add_note(text: mail_text, from: from)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
You can submit mail for processing by calling the process_mail
|
24
|
-
method with a Mail instance:
|
25
|
-
|
26
|
-
MailProcessor.process_mail(Mail.read('/path/to/message.eml'))
|
27
|
-
|
28
|
-
The mail_processor routing tree uses routing methods specific to
|
29
|
-
mail:
|
30
|
-
|
31
|
-
r.from :: match on the mail From address
|
32
|
-
r.to :: match on the mail To address
|
33
|
-
r.cc :: match on the mail CC address
|
34
|
-
r.rcpt :: match on the mail recipients (To and CC addresses by
|
35
|
-
default)
|
36
|
-
r.subject :: match on the mail subject
|
37
|
-
r.body :: match on the mail body
|
38
|
-
r.text :: match on text extracted from the message (same as mail
|
39
|
-
body by default)
|
40
|
-
r.header :: match on a mail header
|
41
|
-
|
42
|
-
To mark a mail as having been handled, you call the r.handle method
|
43
|
-
with a block, or one of the above methods prefixed by handle_
|
44
|
-
(e.g. r.handle_text).
|
45
|
-
|
46
|
-
The mail_processor plugin supports hooks that are called for handled
|
47
|
-
mail, unhandled mail, and all mail (for archiving). It also
|
48
|
-
supports the ability to configure how reply text is parsed out of
|
49
|
-
mail, who to consider as the recipients of the email, and the
|
50
|
-
ability to have separate routing blocks per recipient email address
|
51
|
-
(with O(1) delegation to the appropriate block if the recipient
|
52
|
-
addresses to match is a string).
|
@@ -1,62 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* A route_block_args plugin has been added, allowing you to customize
|
4
|
-
which objects are yielded to the the route block. You call the
|
5
|
-
plugin with a block, which is evaluated in the context of the
|
6
|
-
instance and should return an array of arguments for the instance
|
7
|
-
to yield to the route block.
|
8
|
-
|
9
|
-
To yield both the request and response objects, you can do:
|
10
|
-
|
11
|
-
plugin :route_block_args do |r|
|
12
|
-
[r, response]
|
13
|
-
end
|
14
|
-
|
15
|
-
route do |r, response|
|
16
|
-
# ...
|
17
|
-
end
|
18
|
-
|
19
|
-
In addition to the main route block, using this plugin also affects
|
20
|
-
the arguments passed to routing blocks in the following plugins:
|
21
|
-
|
22
|
-
* class_level_routing
|
23
|
-
* mailer
|
24
|
-
* mail_processor
|
25
|
-
* multi_route
|
26
|
-
* static_routing
|
27
|
-
|
28
|
-
= Other Improvements
|
29
|
-
|
30
|
-
* The set_layout_opts method in the view_options plugin can now
|
31
|
-
override the layout template even if the render plugin :layout
|
32
|
-
option is given.
|
33
|
-
|
34
|
-
* The mailer and mail_processor plugin now integrate with the hooks
|
35
|
-
plugin to support before/after hooks.
|
36
|
-
|
37
|
-
* Dispatching to the route block and RodaResponse#finish are both
|
38
|
-
slightly faster.
|
39
|
-
|
40
|
-
* Internal before hook handling has been moved from an internal
|
41
|
-
plugin into the core, and modified so that if you are not using
|
42
|
-
the internal before hook in any plugin, there is no runtime cost.
|
43
|
-
|
44
|
-
* The core now recognizes when plugins are using the internal after
|
45
|
-
hook, and automatically loads the internal plugin supporting the
|
46
|
-
after hook.
|
47
|
-
|
48
|
-
= Backwards Compatibility
|
49
|
-
|
50
|
-
* When using the render plugin with a :layout option, the render_opts
|
51
|
-
:layout option will be set to true if the layout is enabled.
|
52
|
-
Previously, the render_opts :layout option would retain the value
|
53
|
-
given as the plugin option. Options for the layout (including the
|
54
|
-
template) are still available in the render_opts :layout_opts
|
55
|
-
option. This change was made to fix the set_layout_opts bug in the
|
56
|
-
view_options plugin.
|
57
|
-
|
58
|
-
* RodaResponse#initialize no longer sets the response status to nil
|
59
|
-
if it was already set.
|
60
|
-
|
61
|
-
* RodaResponse#finish no longer sets the status on the receiver, it
|
62
|
-
just uses the receiver's status to set the rack response status.
|
@@ -1,170 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* A direct_call plugin has been added. This plugin makes Roda.call
|
4
|
-
call the app directly, skipping any middleware. This plugin
|
5
|
-
can be used for performance reasons, as the class itself can be
|
6
|
-
used as the base rack app, instead of using a lambda as the base
|
7
|
-
rack app. Roda.app.call will still call all middleware when
|
8
|
-
using this plugin.
|
9
|
-
|
10
|
-
= Other Improvements
|
11
|
-
|
12
|
-
* Blocks that are given during application configuration, and
|
13
|
-
previously executed with instance_exec, instead now define methods,
|
14
|
-
and Roda now calls these methods. This is a much faster approach.
|
15
|
-
This new approach, combined with the direct_call plugin and the
|
16
|
-
Roda.freeze optimizations, can be over 80% faster for trivial
|
17
|
-
applications, with measureable improvements in most applications.
|
18
|
-
|
19
|
-
As methods are strict in regards to arity and instance_exec is
|
20
|
-
not, Roda now checks all such blocks for arity mismatches, and
|
21
|
-
attempts to compensate for arity mismatches. In case of an arity
|
22
|
-
mismatch, Roda will define a method that will call instance_exec,
|
23
|
-
in which case there will not be a performance improvement.
|
24
|
-
|
25
|
-
For some methods, Roda may not know the expected arity until
|
26
|
-
runtime. In that case, Roda will check the arity at runtime and
|
27
|
-
try to call the method with the arity that it supports if there is
|
28
|
-
an arity mismatch.
|
29
|
-
|
30
|
-
You can control the checking of arity via two options:
|
31
|
-
|
32
|
-
:check_arity :: Set to false to turn off all arity checking. Set to
|
33
|
-
:warn to issue a warning when defining the method if
|
34
|
-
there is an arity mismatch (for methods where the
|
35
|
-
expected arity is known in advance).
|
36
|
-
:check_dynamic_arity :: Set to false to turn off arity checking for
|
37
|
-
methods defined where the arity is not known
|
38
|
-
at compile time. Set to :warn to issue a
|
39
|
-
warning at runtime every time the method is
|
40
|
-
called and there is an arity mismatch (for
|
41
|
-
methods where the expected arity is not
|
42
|
-
known in advance). Note that checking the
|
43
|
-
arity at runtime has a performance cost,
|
44
|
-
so for maximum performance this should be
|
45
|
-
set to false.
|
46
|
-
|
47
|
-
Note that this arity checking is only done to keep backwards
|
48
|
-
compatibility. Since lambdas already used strict arity, no arity
|
49
|
-
checking is done if the block is a lambda and not a regular proc.
|
50
|
-
|
51
|
-
Roda has a new dispatch API that works with these defined methods.
|
52
|
-
The new dispatch API uses the following methods:
|
53
|
-
|
54
|
-
* _roda_handle_main_route: Entry point for normal request dispatch.
|
55
|
-
* _roda_handle_route: Yields to the routing block, catching any
|
56
|
-
halts inside the block, treating the block as a routing block.
|
57
|
-
* _roda_main_route: Roda.route defines this method using the
|
58
|
-
block provided, it accepts the request as an argument.
|
59
|
-
* _roda_run_main_route: Calls _roda_main_route with the request,
|
60
|
-
allowing for plugins to execute code around the main routing,
|
61
|
-
while still being able to throw :halt to return a response.
|
62
|
-
|
63
|
-
All instance methods defined by Roda use the _roda_ prefix.
|
64
|
-
|
65
|
-
* When deleting the session cookie in the sessions plugin, the
|
66
|
-
Set-Cookie response header now uses the same path and domain
|
67
|
-
that was originally used to set the cookie. This can fix cases
|
68
|
-
where the cookie was not being cleared as expected.
|
69
|
-
|
70
|
-
* Freezing a Roda app now can add performance improvements in
|
71
|
-
addition to reliability improvements. When freezing the class,
|
72
|
-
if certain methods in the class have not been overridden, Roda
|
73
|
-
now defines aliases or more optimized methods to improve
|
74
|
-
performance.
|
75
|
-
|
76
|
-
* Roda now warns if the Roda#call method is overridden in a module,
|
77
|
-
without the module also overridding _roda_handle_main_route or
|
78
|
-
_roda_run_main_route. This indicates that the module needs
|
79
|
-
to be updated to use Roda's new dispatch API. Roda will continue
|
80
|
-
to work in this case, but it will be slower than the Roda's now
|
81
|
-
default behavior, as it will force usage of the old dispatch API.
|
82
|
-
This check will be removed in Roda 4, which will remove support
|
83
|
-
for Roda#call (and Roda#_call).
|
84
|
-
|
85
|
-
* When there is only a single internal before or after hook defined,
|
86
|
-
the hook is now faster by using a method alias.
|
87
|
-
|
88
|
-
* The route_csrf plugin block or :csrf_failure option proc now
|
89
|
-
integrates with the route_block_args plugin.
|
90
|
-
|
91
|
-
* The default_status plugin is now faster by defining the
|
92
|
-
default_status method directly.
|
93
|
-
|
94
|
-
* The default_headers plugin is now faster by defining an optimized
|
95
|
-
set_default_headers method directly.
|
96
|
-
|
97
|
-
* The hooks plugin is now faster by defining methods for each
|
98
|
-
hook block, with a main hook method that dispatches to each
|
99
|
-
of the hook block methods. If only a single hook block is
|
100
|
-
used, the main hook method is an alias to the hook block
|
101
|
-
method to avoid an extra method call.
|
102
|
-
|
103
|
-
* The following plugins now use define_method instead of
|
104
|
-
instance_exec for better performance:
|
105
|
-
|
106
|
-
* defaults_setter
|
107
|
-
* mail_processor
|
108
|
-
* multi_route
|
109
|
-
* named_templates
|
110
|
-
* path
|
111
|
-
* route_block_args
|
112
|
-
* route_csrf
|
113
|
-
* static_routing
|
114
|
-
* status_handler
|
115
|
-
|
116
|
-
* The internal after hook implementation has now been merged into
|
117
|
-
the error_handler plugin. This is faster in cases where the
|
118
|
-
error_handler plugin is used, and slower in cases where the
|
119
|
-
internal after hook plugin was used without the error_handler
|
120
|
-
plugin.
|
121
|
-
|
122
|
-
* The route_block_args plugin now handles cases where
|
123
|
-
Roda.convert_route_block has already been overridden.
|
124
|
-
|
125
|
-
* Performance of routing methods that can yield captures has been
|
126
|
-
improved.
|
127
|
-
|
128
|
-
* Hash#merge is now used in preference to Hash[].merge! in cases
|
129
|
-
where the receiver of Hash#merge would not be provided by the
|
130
|
-
user. This is because Hash#merge is faster than Hash[].merge!
|
131
|
-
in recent ruby versions. If the receiver of #merge is provided
|
132
|
-
by the user, then Hash[].merge! is still used to ensure that the
|
133
|
-
resulting value is plain hash.
|
134
|
-
|
135
|
-
* The static_routing plugin no longer removes existing static
|
136
|
-
routes if loaded more than once.
|
137
|
-
|
138
|
-
* Roda now warns when calling Roda.route without a block.
|
139
|
-
|
140
|
-
= Backwards Compatibility
|
141
|
-
|
142
|
-
* The route_block_args plugin no longer affects the
|
143
|
-
class_level_routing plugin. Support for this was added in Roda
|
144
|
-
3.17.0 when the route_block_args plugin was added, but this was a
|
145
|
-
mistake as class_level_routing blocks should be called with the
|
146
|
-
captures for their matchers, not with the route block args.
|
147
|
-
|
148
|
-
* Some of the internal state was changed in the following plugins:
|
149
|
-
|
150
|
-
* class_level_routing
|
151
|
-
* mail_processor
|
152
|
-
* multi_route
|
153
|
-
* named_templates
|
154
|
-
* static_routing
|
155
|
-
* status_handler
|
156
|
-
|
157
|
-
This only affects you if you were accessing the internal state
|
158
|
-
via the opts hash.
|
159
|
-
|
160
|
-
* The static_routing plugin no longer defines the r.static_route
|
161
|
-
method.
|
162
|
-
|
163
|
-
* The mailer plugin was switched to use the new dispatch API, and
|
164
|
-
will no longer handle cases where the old dispatch API (Roda#call)
|
165
|
-
was overrridden.
|
166
|
-
|
167
|
-
* The static_route method in the static_routing plugin must
|
168
|
-
now be called with a block. Previously, that would not
|
169
|
-
cause a failure until runtime, where it would fail when
|
170
|
-
you tried to execute the route.
|
@@ -1,229 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* A hash_routes plugin has been added for O(1) route dispatching at
|
4
|
-
any level of the routing tree. By default, Roda uses a linear
|
5
|
-
search of possible branches at each level of the routing tree,
|
6
|
-
which results in roughly O(log(n)) routing behavior in most
|
7
|
-
applications (where n is the total number of routes in the
|
8
|
-
application).
|
9
|
-
|
10
|
-
Assume you have the following routing tree:
|
11
|
-
|
12
|
-
route do |r|
|
13
|
-
r.on "a" do
|
14
|
-
# ...
|
15
|
-
end
|
16
|
-
|
17
|
-
r.on "b" do
|
18
|
-
# ...
|
19
|
-
end
|
20
|
-
|
21
|
-
r.is "c" do
|
22
|
-
# ...
|
23
|
-
end
|
24
|
-
|
25
|
-
# ...
|
26
|
-
end
|
27
|
-
|
28
|
-
With this routing tree, a request for /c will first check /a and
|
29
|
-
/b. This is not normally a performance issue, but if you have a
|
30
|
-
large number of routes at a particular level, it can be.
|
31
|
-
|
32
|
-
The hash_routes plugin allows you to convert this routing tree to:
|
33
|
-
|
34
|
-
plugin :hash_routes
|
35
|
-
|
36
|
-
hash_routes do
|
37
|
-
on "a" do |r|
|
38
|
-
# ...
|
39
|
-
end
|
40
|
-
|
41
|
-
on "b" do |r|
|
42
|
-
# ...
|
43
|
-
end
|
44
|
-
|
45
|
-
is "c" do |r|
|
46
|
-
# ...
|
47
|
-
end
|
48
|
-
|
49
|
-
# ...
|
50
|
-
end
|
51
|
-
|
52
|
-
route do |r|
|
53
|
-
r.hash_routes
|
54
|
-
end
|
55
|
-
|
56
|
-
This routing tree looks similar to Roda's standard routing tree, and
|
57
|
-
will have the same behavior as the previous example, but dispatching
|
58
|
-
to the routes inside the hash_routes block by the r.hash_routes
|
59
|
-
method will be an O(1) operation, instead of a linear search. This
|
60
|
-
can significantly improve performance in cases where you have a large
|
61
|
-
number of branches at any point in the routing tree.
|
62
|
-
|
63
|
-
In order to support O(1) route dispatching at any level of the
|
64
|
-
tree, the hash_routes plugin supports namespaces. You can use this
|
65
|
-
namespace support to keep the primary advantage of Roda when using
|
66
|
-
the hash_routes plugin, which is the ability to operate on a request
|
67
|
-
at any point during routing. Assume you have this routing tree:
|
68
|
-
|
69
|
-
hash_routes :root do
|
70
|
-
on "foo" do |r|
|
71
|
-
r.on Integer do |foo_id|
|
72
|
-
next unless @foo = Foo[foo_id]
|
73
|
-
r.hash_routes(:foo)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
on "bar" do |r|
|
78
|
-
r.on Integer do |bar_id|
|
79
|
-
next unless @bar = Bar[bar_id]
|
80
|
-
r.hash_routes(:bar)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# ...
|
85
|
-
end
|
86
|
-
|
87
|
-
hash_routes :foo do
|
88
|
-
get "show" do
|
89
|
-
@page_title = @foo.name
|
90
|
-
view('foo/show')
|
91
|
-
end
|
92
|
-
|
93
|
-
# ...
|
94
|
-
end
|
95
|
-
|
96
|
-
hash_routes :bar do
|
97
|
-
post "edit" do
|
98
|
-
@bar.update(:name=>request.params['name'])
|
99
|
-
r.redirect "/"
|
100
|
-
end
|
101
|
-
|
102
|
-
# ...
|
103
|
-
end
|
104
|
-
|
105
|
-
route do |r|
|
106
|
-
r.hash_routes(:root)
|
107
|
-
end
|
108
|
-
|
109
|
-
With this routing tree, a GET /foo/123/show request will first get
|
110
|
-
dispatched to the on "foo" block in the :root namespace. That will
|
111
|
-
extract the 123 segment from the path, and use it to find the Foo
|
112
|
-
object with id 123 and set that to the instance variable @foo.
|
113
|
-
If there is no matching foo, the rest of the block will be skipped,
|
114
|
-
which will result in a 404 response. If there is a matching foo,
|
115
|
-
after setting the instance variable, it will dispatch to routes in
|
116
|
-
the :foo namespace, one of which is show, which will be able to use
|
117
|
-
the @foo variable, both in the route and in the view.
|
118
|
-
|
119
|
-
Similarly, a POST /bar/321/edit request would dispatch to the on
|
120
|
-
"bar" block in the :root namespace, will look up the matching bar,
|
121
|
-
then will dispatch to the edit route in the :bar namespace.
|
122
|
-
|
123
|
-
The hash_routes plugin can be used as a faster version of the
|
124
|
-
multi_route plugin's r.multi_route method. It can also be used as
|
125
|
-
a faster replacement for the multi_view plugin.
|
126
|
-
|
127
|
-
Please see the hash_routes plugin documentation for additional
|
128
|
-
methods and configuration styles supported by the plugin.
|
129
|
-
|
130
|
-
* A match_hook plugin has been added, which is called for each
|
131
|
-
successful match, before yielding to the match block. For example,
|
132
|
-
with the following routing tree:
|
133
|
-
|
134
|
-
plugin :match_hook
|
135
|
-
|
136
|
-
match_hook do
|
137
|
-
puts "#{r.matched_path}|#{r.remaining_path}"
|
138
|
-
end
|
139
|
-
|
140
|
-
route do |r|
|
141
|
-
r.on "a" do
|
142
|
-
r.is "b" do
|
143
|
-
r.get do
|
144
|
-
end
|
145
|
-
|
146
|
-
r.post do
|
147
|
-
end
|
148
|
-
end
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
A GET request for /a/b would call the match hook three times, and
|
153
|
-
output the following:
|
154
|
-
|
155
|
-
/a|/b # When the r.on block matches
|
156
|
-
/a/b| # When the r.is block matches
|
157
|
-
/a/b| # When the r.get block matches
|
158
|
-
|
159
|
-
A GET request for /a/c would call the match hook once, and output
|
160
|
-
the following:
|
161
|
-
|
162
|
-
/a|/b # When the r.on block matches
|
163
|
-
|
164
|
-
This plugin can be used to make debugging easier, as well as for
|
165
|
-
metrics.
|
166
|
-
|
167
|
-
= Other Improvements
|
168
|
-
|
169
|
-
* Per-cookie cipher secrets are now supported and used automatically
|
170
|
-
by default in the sessions plugin. This can prevent issues where
|
171
|
-
the cipher secret can be leaked if the random initialization vector
|
172
|
-
turns out not to be so random and ends up being reused. This
|
173
|
-
makes the session cookies slightly larger and about 10-20% slower.
|
174
|
-
|
175
|
-
Note that because of the way the sessions plugin is designed,
|
176
|
-
even if the cipher secret was leaked and you are not using
|
177
|
-
per-cookie cipher secrets, it would not allow an attacker to
|
178
|
-
forge a session, it would only allow them to read the contents of
|
179
|
-
an existing session.
|
180
|
-
|
181
|
-
If you are currently using the sessions plugin, and performing
|
182
|
-
rolling restarts, you should temporarily disable per-cookie session
|
183
|
-
secrets until all processes have been restarted and are able to
|
184
|
-
support per-cookie session secrets. You can do so by setting the
|
185
|
-
:per_cookie_cipher_secret sessions plugin option to false
|
186
|
-
temporarily until all processes have restarted and are running Roda
|
187
|
-
3.19.0+.
|
188
|
-
|
189
|
-
* When passing route blocks to Roda that have 0 arity instead of the
|
190
|
-
expected arity of 1, emulate an arity of 1 using an approach that is
|
191
|
-
about 2.75-8x faster. This emulation is still about 20% slower than
|
192
|
-
using the expected arity.
|
193
|
-
|
194
|
-
* Fix emulation of route blocks that have >1 arity but where the
|
195
|
-
expected arity is 1. Such blocks were not handled correctly in
|
196
|
-
Roda 3.18.0.
|
197
|
-
|
198
|
-
* String matching performance has been improved by 10-20%.
|
199
|
-
|
200
|
-
* Symbol and String class matching performance has improved by 10-20%.
|
201
|
-
|
202
|
-
* Terminal matching performance has improved by about 4x.
|
203
|
-
|
204
|
-
* Roda will now automatically load the direct_call plugin when
|
205
|
-
freezing the application if there is no middleware used and the
|
206
|
-
application has not been subclassed, for improved performance.
|
207
|
-
|
208
|
-
* Roda no longer builds the rack application until the app class
|
209
|
-
method is called. This can fix O(n^2) issues when building
|
210
|
-
applications with a lot of middleware. One consequence of
|
211
|
-
this is that a Roda.route block is no longer required. If
|
212
|
-
Roda.route is not called, then the default routing tree will
|
213
|
-
return a 404 response for all requests.
|
214
|
-
|
215
|
-
The delay_build plugin used to support delaying building the rack
|
216
|
-
application until a build! method is called. Now that Roda delays
|
217
|
-
building the rack application until the app method is called, there
|
218
|
-
is no reason to use this plugin, and it is now a no-op.
|
219
|
-
|
220
|
-
* The assets plugin :timestamp_paths option now supports a string
|
221
|
-
value to use a custom separator. A slash separator is still used
|
222
|
-
by default.
|
223
|
-
|
224
|
-
= Backwards Compatibility
|
225
|
-
|
226
|
-
* The static_routing plugin internals have changed, as the
|
227
|
-
static_routing is now implemented via the hash_routes plugin. If
|
228
|
-
you were depending on the internals, you will need to update your
|
229
|
-
code.
|
data/doc/release_notes/3.2.0.txt
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* A timestamp_public plugin has been added for serving static files
|
4
|
-
with paths that change based on the modification timestamp of the
|
5
|
-
file. By using a new path, cached versions of the file will not
|
6
|
-
be used, fixing staleness issues. Example:
|
7
|
-
|
8
|
-
plugin :timestamp_public
|
9
|
-
|
10
|
-
route do |r|
|
11
|
-
# serves requests for /static/\d+/.*
|
12
|
-
r.timestamp_public
|
13
|
-
|
14
|
-
# /static/1234567890/path/to/file
|
15
|
-
timestamp_path("path/to/file")
|
16
|
-
end
|
17
|
-
|
18
|
-
= Other Improvements
|
19
|
-
|
20
|
-
* When using the assets plugin :timestamp_paths option, the
|
21
|
-
timestamps now include microseconds, to make cache poisoning more
|
22
|
-
difficult.
|
@@ -1,7 +0,0 @@
|
|
1
|
-
= Improvements
|
2
|
-
|
3
|
-
* For empty responses with status code 205, a Content-Length header
|
4
|
-
is now added with a value of 0, for better conformance to RFC 7232.
|
5
|
-
|
6
|
-
Similarly, when using the drop_body plugin, responses with status
|
7
|
-
code 205 now have a Content-Length header added with a value of 0.
|
@@ -1,24 +0,0 @@
|
|
1
|
-
= Improvements
|
2
|
-
|
3
|
-
* The render/view methods in the render plugin, when called with
|
4
|
-
a single string/symbol argument (the most common case), are now
|
5
|
-
up to 2.5x/4x faster by directly calling compiled template methods.
|
6
|
-
This works by extracting the UnboundMethod objects that Tilt
|
7
|
-
creates, and defining real methods for them, then calling those
|
8
|
-
methods using send. This avoids most of the overhead of the render
|
9
|
-
and view methods. The compiled template methods are defined inside
|
10
|
-
a module included in the Roda app's class, so this support works
|
11
|
-
even if the Roda app itself is frozen.
|
12
|
-
|
13
|
-
Some plugins, such as render_locals, do not work with this
|
14
|
-
optimization, and disable the use of it. The view_options plugin
|
15
|
-
does work with this optimization if you are using set_view_subdir or
|
16
|
-
append_view_subdir, but not if using set_view_options or
|
17
|
-
set_layout_options.
|
18
|
-
|
19
|
-
This optimization depends on Ruby 2.3+ and Tilt 1.2+, and will not
|
20
|
-
be used on earlier versions, or if an API change in Tilt is
|
21
|
-
detected.
|
22
|
-
|
23
|
-
* Session deserialization is now slightly faster in the sessions
|
24
|
-
plugin.
|
@@ -1,28 +0,0 @@
|
|
1
|
-
= Improvements
|
2
|
-
|
3
|
-
* The render/view methods in the render plugin, when called with
|
4
|
-
a single string/symbol argument (the most common case), are now
|
5
|
-
up to 2x faster in cache: false mode by directly calling compiled
|
6
|
-
template methods. This takes the performance increase in 3.22.0
|
7
|
-
and applies it to cache: false mode in addition to cache: true
|
8
|
-
mode. If the template file has changed, the compiled method is
|
9
|
-
removed, and a new compiled method replaces it.
|
10
|
-
|
11
|
-
* Template modification detection in the render plugin now uses a
|
12
|
-
faster check for modification, which also avoids a race condition.
|
13
|
-
|
14
|
-
* The type_routing plugin now handles requests with nothing but the
|
15
|
-
extension in the request path. This fixes cases when you have
|
16
|
-
one app partially route a request, and send the request to another
|
17
|
-
app, and that app uses the type_routing plugin and has an r.is
|
18
|
-
call at the root level.
|
19
|
-
|
20
|
-
* The roda/session_middleware middleware now works correctly if the
|
21
|
-
type_routing plugin is loaded into Roda itself (as opposed to a
|
22
|
-
Roda subclass).
|
23
|
-
|
24
|
-
* The exception_page plugin now always shows the line number for
|
25
|
-
each line. Previously, it only showed the line number if it was
|
26
|
-
showing the content of the line, which complicated debugging in
|
27
|
-
cases where the content of the line was no longer retrievable
|
28
|
-
due to file system permissions or restrictions (e.g. chroot).
|
@@ -1,14 +0,0 @@
|
|
1
|
-
= Improvements
|
2
|
-
|
3
|
-
* The performance of the render_each plugin has been dramatically
|
4
|
-
improved by calling compiled template methods directly. For a simple
|
5
|
-
template, render_each performance with a single object can be about
|
6
|
-
2x faster, and render_each performance for 100 objects can be 3x
|
7
|
-
(cache: false) to 9x (cache: true) faster.
|
8
|
-
|
9
|
-
This optimization can be used if no options are provided to
|
10
|
-
render_each, or if :local and/or :locals options are provided. Use
|
11
|
-
of other options will disable this optimization.
|
12
|
-
|
13
|
-
* The module_include plugin no longer calls Proc.new without a
|
14
|
-
block, fixing a warning on Ruby 2.7.
|
@@ -1,12 +0,0 @@
|
|
1
|
-
= Improvements
|
2
|
-
|
3
|
-
* The new tilt 2.0.10 private API is now supported when using
|
4
|
-
compiled template methods, with up to a 33% performance increase.
|
5
|
-
The older tilt private API (back to tilt 1.2) is still supported.
|
6
|
-
|
7
|
-
* The performance of the render and view methods in the render plugin
|
8
|
-
when called with only the :locals option are now about 75% faster
|
9
|
-
by calling compiled template methods directly.
|
10
|
-
|
11
|
-
* Keyword argument separation issues are now handled on Ruby 2.7+
|
12
|
-
when defining methods with blocks that accept keyword arguments.
|
@@ -1,15 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* Asynchronous streaming is now supported in the streaming plugin,
|
4
|
-
using the :async option. When using this option, streaming
|
5
|
-
responses are temporarily buffered in a queue. By default, the
|
6
|
-
queue is a sized queue with a maximum of 10 elements, but the
|
7
|
-
queue can be specified manually via the :queue option, which
|
8
|
-
can be used with async libraries that support non-blocking
|
9
|
-
queues. This option is currently only supported on Ruby 2.3+.
|
10
|
-
|
11
|
-
= Other Improvements
|
12
|
-
|
13
|
-
* When combining multiple compiled assets into a single file, the
|
14
|
-
files are now separated by a newline, fixing issues when a
|
15
|
-
single line comment is used as the last line of a file.
|
@@ -1,15 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* A multibyte_string_matcher plugin has been added that supports
|
4
|
-
multibyte characters in strings used as matchers. It uses a slower
|
5
|
-
string matching implementation that supports multibyte characters.
|
6
|
-
As multibyte strings in paths must be escaped, this also loads the
|
7
|
-
unescape_path plugin.
|
8
|
-
|
9
|
-
= Other Improvements
|
10
|
-
|
11
|
-
* The json_parser plugin now returns expected results for invalid JSON
|
12
|
-
if the params_capturing plugin is used.
|
13
|
-
|
14
|
-
* lib/roda.rb has been split into multiple files for easier code
|
15
|
-
navigation.
|
@@ -1,13 +0,0 @@
|
|
1
|
-
= New Features
|
2
|
-
|
3
|
-
* The sessions plugin now supports RodaRequest#session_created_at
|
4
|
-
and RodaRequest#session_updated_at for the times of session
|
5
|
-
creation and last update.
|
6
|
-
|
7
|
-
= Other Improvements
|
8
|
-
|
9
|
-
* The json_parser plugin now correctly parses the request body even
|
10
|
-
if the request body has already been read.
|
11
|
-
|
12
|
-
* The sessions plugin now correctly handles upgrading rack cookie
|
13
|
-
sessions when using rack 2.0.8+.
|