2.0.0
This version adds the default
matcher and two new primitives: consume
(match and consume a path segment) and capture
(match and capture a path segment, then store the value in the inbox). The reason for providing consume
and capture
has to do with the fact that a framework using Syro can create new matchers, for example it could provide a matcher that behaves like path captures in Cuba.
Normally, you can capture a path segment and access the value using the inbox:
on(:post_id) do
res.write inbox[:post_id]
end
A custom Desk
could implement the with
matcher:
def with(arg)
default { yield(inbox[arg]) } if capture(arg)
end
Then, it could be used as follows:
with(:post_id) do |post_id|
...
end
The functionality to yield the capture to the block was included in version 1.0.0
, and it was removed in this release because the implementation performed hash lookups in all matches.
Deck
creators can also redefine the on matcher as follows:
def on(arg)
default { yield(inbox[arg]) } if match(arg)
end
This version encourages the use of the inbox instead, and encourages framework authors to create a with
matcher if they want that behaviour. The code is production ready.