Hatena::Groupcatalyst

LAPISLAZULI HILL#Catalyst このページをアンテナに追加 RSSフィード

2007-01-05

[][]Chain#04 Chain#04 - LAPISLAZULI HILL#Catalyst を含むブックマーク はてなブックマーク - Chain#04 - LAPISLAZULI HILL#Catalyst Chain#04 - LAPISLAZULI HILL#Catalyst のブックマークコメント

こんな感じでどうだろう?

を実現するのに

sub user : Chained('/') PathPart('') CaptureArgs(1) {
    my ($self, $c, $user) = @_;
    $c->stash->{ user } = $user;
}

sub list : Chained('user') PathPart('') Args(0) {
    my ($self, $c) = @_;
    $c->stash->{ message } = "'s list";
}

sub detail : Chained('user') PathPart('detail') Args(1) {
    my ($self, $c, $url) = @_;
    $c->stash->{ message } = " detail => " .$url;
}

sub add : Chained('user') PathPart('add') Args(1) {
    my ($self, $c, $url) = @_;
    $c->stash->{ message } .= " add url => " .$url;
}

sub edit : Chained('user') PathPart('edit') Args(1) {
    my ($self, $c, $url) = @_;
    $c->stash->{ message } .= " edit url => " .$url;
}

sub del : Chained('user') PathPart('del') Args(1) {
    my ($self, $c, $url) = @_;
    $c->stash->{ message } .= " delete url => " .$url;
}

sub end : ActionClass('RenderView') {
    my ($self, $c) = @_;
    $c->response->body( $c->stash->{ user }.$c->stash->{ message });
}

下の4つは同じ

最後の(url)を/が入っても全部取るならArgsの数の指定をやめればすべて取ってくれる

sub add : Chained('user') PathPart('add') Args {
    my ($self, $c, @url) = @_;
    $c->stash->{ message } .= " add url => " .join "/", @url;
}
[debug] Loaded Chained actions:
.-------------------------------------+--------------------------------------.
| Path Spec                           | Private                              |
+-------------------------------------+--------------------------------------+
| /*/add/...                          | /user (1)                            |
|                                     | => /add                              |
| /*/del/...                          | /user (1)                            |
|                                     | => /del                              |
| /*/detail/...                       | /user (1)                            |
|                                     | => /detail                           |
| /*/edit/...                         | /user (1)                            |
|                                     | => /edit                             |
| /*                                  | /user (1)                            |
|                                     | => /list                             |
'-------------------------------------+--------------------------------------'

ふむ

ddeqcaddeqca2007/04/11 12:47<a href=http://roccofoloper.sblog.cz>sauna belt</a> sauna belt http://roccofoloper.sblog.cz sauna belt

トラックバック - http://catalyst.g.hatena.ne.jp/lapis25/20070105