| 1 | package Chaostr::Web::Base::Controller; |
|---|
| 2 | |
|---|
| 3 | use strict; |
|---|
| 4 | use warnings; |
|---|
| 5 | use base 'Catalyst::Controller::Resource'; |
|---|
| 6 | use Catalyst::Utils; |
|---|
| 7 | |
|---|
| 8 | |
|---|
| 9 | # __PACKAGE__->config( |
|---|
| 10 | # collection => { |
|---|
| 11 | # list => { method => 'GET', path => '' }, |
|---|
| 12 | # create => { method => 'POST', path => '' }, |
|---|
| 13 | # create_form => { method => 'GET', path => 'new' }, |
|---|
| 14 | # }, |
|---|
| 15 | # member => { |
|---|
| 16 | # show => { method => 'GET', path => '' }, |
|---|
| 17 | # update => { method => 'POST', path => 'update' }, |
|---|
| 18 | # update_form => { method => 'GET', path => 'update' }, |
|---|
| 19 | # destroy => { method => 'POST', path => 'delete' }, |
|---|
| 20 | # destroy_form => { method => 'GET', path => 'delete' }, |
|---|
| 21 | # edit => { method => 'GET', path => 'edit' }, |
|---|
| 22 | # edit_form => { method => 'GET', path => 'edit' }, |
|---|
| 23 | # }, |
|---|
| 24 | # ); |
|---|
| 25 | |
|---|
| 26 | sub setup_collection_actions { |
|---|
| 27 | my $self = shift; |
|---|
| 28 | |
|---|
| 29 | my $maps = Catalyst::Utils::merge_hashes($self->{collection} || {}, { |
|---|
| 30 | list => { method => 'GET', path => '' }, |
|---|
| 31 | do_create => { method => 'POST', path => '' }, |
|---|
| 32 | create => { method => 'GET', path => 'new' }, |
|---|
| 33 | }); |
|---|
| 34 | $self->setup_actions(collection => $maps); |
|---|
| 35 | } |
|---|
| 36 | |
|---|
| 37 | sub setup_member_actions { |
|---|
| 38 | my $self = shift; |
|---|
| 39 | |
|---|
| 40 | my $maps = Catalyst::Utils::merge_hashes($self->{member} || {}, { |
|---|
| 41 | show => { method => 'GET', path => '' }, |
|---|
| 42 | do_update => { method => 'POST', path => 'update' }, |
|---|
| 43 | update => { method => 'GET', path => 'update' }, |
|---|
| 44 | do_destroy => { method => 'POST', path => 'delete' }, |
|---|
| 45 | destroy => { method => 'GET', path => 'delete' }, |
|---|
| 46 | }); |
|---|
| 47 | $self->setup_actions(member => $maps); |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | 1; |
|---|