Hi all, A new release of Dancer1 has been cut, and is on its merry way to CPAN. Beside the documentation improvements and general bug fixes, two highlights for this release: 1. the bundled jQuery has been upgraded to v1.11.0. 2. route sanity check has been modified for existence, not falsehood. The main impact is that the following now works: prefix "/foo" => { get '' => { ... }; # matches '/foo'! get '/' => { ... }; # matches '/foo/' get '/bar' => { ... }; matches '/foo/bar' }; Full release log is below. As usual, a big, big thank to everybody who made this release possible. You all rock. :-) Joy, `/anick 1.3124 2014-05-09 [ ENHANCEMENTS ] * Also check X-Forwarded-Proto. (GH#1015, Andy Jones) * Update bundle jQuery to v1.11.0. (GH#1018, Michal Wojciechowski) * Add session support to the skeleton config. (GH#1008. Gabor Szabo) [ BUG FIXES ] * Remove print statement in Dancer::ModuleLoad::require. (GH#1021, John Wittkoski) * Test was failing if JSON module was absent. (GH#1022, Yanick Champoux) * Allow for routes evaluating to false ('0', '', etc). (GH#1020, Yanick Champoux) [DOCUMENTATION] * Specify defaults in POD. (GH#1023, isync) * Fix doc for params(). (GH#1025, reported by Warren Young) [ MISC ] * Update mailing list url in README. (GH#1017, Racke) * Markdownify the README. (GH#986, Chris Seymour)
On Sat, 10 May 2014, Yanick Champoux wrote: [...]
2. route sanity check has been modified for existence, not falsehood. The main impact is that the following now works:
prefix "/foo" => { get '' => { ... }; # matches '/foo'!
get '/' => { ... }; # matches '/foo/'
get '/bar' => { ... }; matches '/foo/bar' };
A note about the first route: If you have a directory foo in your documentroot, servers like apache can give you an intermal redirect to /foo/ I use this, so before I can use the empty route I will have to change my deployment. -- Henk
On 5/10/2014 10:23, Yanick Champoux wrote:
A new release of Dancer1 has been cut, and is on its merry way to CPAN.
Yay!
prefix "/foo" => { get '' => { ... }; # matches '/foo'!
get '/' => { ... }; # matches '/foo/'
Is there a way to match both requests with a single route? That is, can I ask Dancer to ignore trailing slashes? Dancer's sensitivity to this makes it behave differently than Apache serving static content, where /foo and /foo/ do the same thing.
* Fix doc for params(). (GH#1025, reported by Warren Young)
Thank you! The fixes are functionally correct, though if you will accept an inline patch, the English needs a bit of work. I propose that you leave the first two sentences and the last alone, and put this between: "...In list context, it returns a list of key => value pairs for all defined parameters. In scalar context, it returns a hash reference instead...." Rationale: - "an hash" is incorrect American English (http://goo.gl/LNLLs7) at least. I doubt it's correct for Commonwealth English as well, since I don't believe they pronounce "hash" the same as "ash". - Moved the parentheticals inline - Changed the return type in list context to list, since that's less confusing. You can assign the return value to a hash or a list.
On 14-05-12 01:24 PM, Warren Young wrote:
Is there a way to match both requests with a single route? That is, can I ask Dancer to ignore trailing slashes?
Yup. prefix '/foo' => sub { get qr#/?$# => sub { "tadah!"; }; }; Or, as a general rule: hook before => sub { my $url = request->uri; redirect $url if $url =~ s#(?<=.)/$##; };
- "an hash" is incorrect American English (http://goo.gl/LNLLs7) at least. I doubt it's correct for Commonwealth English as well, since I don't believe they pronounce "hash" the same as "ash".
That might 'ave more to do with a... more Frenchie type of pronunciation. It might 'ave been reported, from time to time, that I do tend to aspire my H's. ;-) I'll correct that and the rest. Thanks! Joy, `/anick
On May 12, 2014, at 7:37 PM, Yanick Champoux <yanick@babyl.dyndns.org> wrote:
On 14-05-12 01:24 PM, Warren Young wrote:
can I ask Dancer to ignore trailing slashes?
hook before => sub { my $url = request->uri; redirect $url if $url =~ s#(?<=.)/$##; };
I’m guessing the only reason you have that lookbehind in there is to prevent the substitution from breaking the top-level ‘/‘ route? Also, is there anything wrong with using “forward” here instead of “redirect”? I’d rather save the HTTP round-trip and not “correct” the browser, as my app really does not care.
On 14-05-13 02:53 AM, Warren Young wrote:
hook before => sub {
my $url = request->uri; redirect $url if $url =~ s#(?<=.)/$##; };
I’m guessing the only reason you have that lookbehind in there is to prevent the substitution from breaking the top-level ‘/‘ route?
Yup, that's it.
Also, is there anything wrong with using “forward” here instead of “redirect”? I’d rather save the HTTP round-trip and not “correct” the browser, as my app really does not care.
Just switching the redirect for a forward will cause an error. But I think that with a judicious use of 'halt' and munging of the 'response' object, that'd be entirely possible. Joy, `/anick
participants (3)
-
Henk van Oers -
Warren Young -
Yanick Champoux