The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Catalyst::Plugin::BuildURI - Build URI by action name, namespace, and args

SYNOPSIS

  package MyApp;

  use Catalyst qw/BuildURI/;

  MyApp->config(
    name => 'MyApp',
    build_uri => {
      'app' => 'http://app.art-code.org/',
      'img' => 'http://img.art-code.org/'
    }
  );

  ...

  package MyApp::Controller::Foo::Bar

  sub redirect_target: Regex('^target/(\d{4})/(\d{2})$') {
    my ($self, $c) = @_;

    # some code
  }

  sub redirect_action: Local {
    my ($self, $c) = @_;

    # redirect to "http://www.art-code.org/target/2006/10/?id=zigorou&password=hogehoge"
    $c->response->redirect($c->build_uri('foo/bar', 'redirect_target', [2006, 10], {id => 'zigorou', password => 'hogehoge'}, 'http://www.art-code.org/'));
  }

  sub labeled_redirect_action: Local {
    my ($self, $c) = @_;

    # redirect to "http://app.art-code.org/target/1976/12/?id=zigorou&password=hogehoge"
    $c->response->redirect($c->build_uri_by_label('foo/bar', 'labeled_redirect_action', [1976, 12], 'id=zigorou&password=hogehoge', 'app'));
  }

  ...

  [%# in template %]
  <a href="[% $c.build_uri('foo/bar', 'redirect_target', [2006, 10], {id => 'zigorou', password => 'hogehoge'}, 'http://www.art-code.org/') %]" title="test">redirect to</a>

DESCRIPTION

This module is building uri string from namespace, action name, args or other.

METHODS

build_uri($namespace, $action_name, $args, $base_uri)

Build URI using namespace, action name, args. optional parameter is base_uri. default is $c->request->uri->as_string;

build_uri_by_label($namespace, $action_name, $args, $base_uri)

Build URI by labeled base_uri. Please setting labeled base_uri to config of your application.

SEE ALSO

Catalyst. URI.

AUTHOR

Toru Yamaguchi <zigorou@cpan.org>

LICENCE AND COPYRIGHT

Copyright (c) 2006, Toru Yamaguchi <zigorou@cpan.org>. All rights reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See perlartistic.