Hatena::Groupangelos

Routingの作成

Fork me on GitHub

Routingの作成

pathとController, actionへのマッピングを規定.

$ vim conf/routes.pl

HTTP::Router->define(
    sub {
        $_->match('/')->to( { controller => 'Root', action => 'index' } );
    }   
);

複数のルールを書く場合

HTTP::Router->define(
    sub {
        $_->match('/')->to( { controller => 'Root', action => 'index' } );
        $_->resources('Book');
    }   
);

RESTfulなルールを各場合

BookがController名

HTTP::Router->define(
    sub {
        $_->resources('Book');
    }   
);

see also: HTTP::Router