| 1 | package Silki::Action::REST; | ||
| 2 | { | ||
| 3 | $Silki::Action::REST::VERSION = '0.29'; | ||
| 4 | } | ||
| 5 | |||
| 6 | use strict; | ||
| 7 | use warnings; | ||
| 8 | use namespace::autoclean; | ||
| 9 | |||
| 10 | use Moose; | ||
| 11 | |||
| 12 | extends 'Catalyst::Action::REST'; | ||
| 13 | |||
| 14 | override dispatch => sub { | ||
| 15 | my $self = shift; | ||
| 16 | my $c = shift; | ||
| 17 | |||
| 18 | if ( $c->request()->looks_like_browser() | ||
| 19 | && uc $c->request()->method() eq 'GET' ) { | ||
| 20 | my $controller = $self->class(); | ||
| 21 | my $method = $self->name() . '_GET_html'; | ||
| 22 | |||
| 23 | if ( $controller->can($method) ) { | ||
| 24 | $c->execute( $self->class, $self, @{ $c->req->args } ); | ||
| 25 | |||
| 26 | return $controller->$method( $c, @{ $c->request()->args() } ); | ||
| 27 | } | ||
| 28 | } | ||
| 29 | |||
| 30 | return super(); | ||
| 31 | }; | ||
| 32 | |||
| 33 | # Intentionally not immutable. Catalyst should take care of this for us, I | ||
| 34 | # think. | ||
| 35 | |||
| 36 | 1; | ||
| 37 | |||
| 38 | # ABSTRACT: Extends dispatch to add get_FOO_html | ||
| 39 | |||
| 40 | __END__ |