[Catalyst] Dispatching not working as expected.

Ian.Docherty at nomura.com Ian.Docherty at nomura.com
Thu May 12 09:29:03 GMT 2011


Hi
I thought I had a grip on this, but obviously I am missing some nuance.

I wish to match the following URLs to controllers.

  /
  /*
  /*/*
  /pod
  /pod/*

All the above work correctly, with the exception of '/pod/*' which dispatches
as if it were '/*/*'.

My understanding is that the most specific should be chosen first, so '/pod/*' 
should be chosen in preference to '/*/*'?

Currently running Catalyst 5.80030

My Root.pm is as follows.

---------
package myapp::Controller::Root;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller' }

__PACKAGE__->config->{namespace} = '';

sub index : Path('/') : Args(0) {
    my ( $self, $c ) = @_;
    $c->response->body( 'index' );
}
sub api : Chained('/') PathPart('') CaptureArgs(1) {
    my ($self, $c, $item) = @_;
    $c->stash->{item} = $item;
}
sub path_without_arg :Chained('api') :PathPart('') :Args(0) {
    my ($self, $c) = @_;
    $c->response->body( "path_without_arg - item ".$c->stash->{item} );
}
sub path_with_arg :Chained('api') :PathPart('') :Args(1) {
    my ($self, $c, $arg) = @_;
    $c->response->body( "path_with_arg - item ".$c->stash->{item}." arg $arg" );
}
__PACKAGE__->meta->make_immutable;
1;

---------
My Pod.pm is as follows
---------

package myapp::Controller::Pod;
use Moose;
use namespace::autoclean;

BEGIN { extends 'Catalyst::Controller' }

sub pod_index : Path('') : Args(0) {
    my ($self, $c) = @_;
    $c->response->body( "pod_index" );
}
sub pod : Path('/pod') : Args(1) {
    my ($self, $c, $file) = @_;
    $c->response->body( "pod - file = $file" );
}
__PACKAGE__->meta->make_immutable;
1;
---------

Regards
Ian Docherty




This e-mail (including any attachments) is confidential, may contain
proprietary or privileged information and is intended for the named
recipient(s) only. Unintended recipients are prohibited from taking action
on the basis of information in this e-mail and must delete all copies.
Nomura will not accept responsibility or liability for the accuracy or
completeness of, or the presence of any virus or disabling code in, this
e-mail. If verification is sought please request a hard copy. Any reference
to the terms of executed transactions should be treated as preliminary only
and subject to formal written confirmation by Nomura. Nomura reserves the
right to monitor e-mail communications through its networks (in accordance
with applicable laws). No confidentiality or privilege is waived or lost by
Nomura by any mistransmission of this e-mail. Any reference to "Nomura" is
a reference to any entity in the Nomura Holdings, Inc. group. Please read
our Electronic Communications Legal Notice which forms part of this e-mail:
http://www.Nomura.com/email_disclaimer.htm




More information about the Catalyst mailing list