Browse files

Patch to allow accessor request->route_pattern

This patch allows a Dancer app to know which route pattern won the
request matching.

This can be very useful for introspection in before filters or plugins.

I know we plan to rewrite all the itnernal API and that this patch is not
the best way to do it, but it's very minimalist and mostly harmless.

On the other hand it fills a gap we have regarding basic introspection
and I need this at work. I want to avoid forking Dancer at work, as much as possible.
  • Loading branch information...
1 parent e9069a5 commit be44dd4bb8489c65374d5e4f8a5f0d08049627a5 Alexis Sukrieh committed Dec 16, 2010
Showing with 4 additions and 1 deletion.
  1. +1 −1 lib/Dancer/
  2. +3 −0 lib/Dancer/
@@ -27,7 +27,7 @@ Dancer::Request->attributes(
'content_type', 'content_length',
'body', 'id', 'request_uri',
'uploads', 'headers', 'path_info',
- 'ajax',
+ 'ajax', 'route_pattern',
@@ -93,6 +93,9 @@ sub match {
return unless @values;
+ # save the route pattern that matched
+ $request->route_pattern($self->pattern);
# named tokens
my @tokens = @{$self->{_params} || []};

2 comments on commit be44dd4


fcuny replied Dec 16, 2010

I would suggest to rename "route_pattern" to "_route_pattern".

If we decide to change the behavior of this method for 1.4, it will easier if the method is not public, as nearly no one should rely on this method :)


sukria replied Dec 16, 2010

Full ACK on this, I totally agree with you. This should not be used unless necessary, and this should not be documented either. This is "under the hood cooking" ;)

Will do the change and provide the patch in 1.2003_01

Please sign in to comment.