| 1 | #!perl | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Web::Machine; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | =pod | ||||||||||
| 9 | |||||||||||
| 10 | curl -v http://0:5000/ | ||||||||||
| 11 | |||||||||||
| 12 | curl -v http://0:5000/edit/100 | ||||||||||
| 13 | |||||||||||
| 14 | =cut | ||||||||||
| 15 | |||||||||||
| 16 | { | ||||||||||
| 17 | package YAPC::NA::2012::Example120::Resource; | ||||||||||
| 18 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 19 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 20 | 1 | ▶ | use Web::Machine::Util qw[ bind_path ]; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 21 | |||||||||||
| 22 | 1 | ▶ | use parent 'Web::Machine::Resource'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 23 | |||||||||||
| 24 | 6 | ▶ | sub content_types_provided { [{ 'text/html' => 'to_html' }] } | ||||||||
|
Subroutine
content_types_provided: called CC=1 SCAR=0.0
| |||||||||||
| 25 | |||||||||||
| 26 | 2 | ▶ | sub to_html { | ||||||||
|
Subroutine
to_html: called CC=2 SCAR=6.9
| |||||||||||
| 27 | 2 | my $self = shift; | |||||||||
| 28 | 2 | ▶ | if ( my ($action, $id) = bind_path( '/:action/:id', $self->request->path_info ) ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 29 | 1 | return "<html><body><h1>action('$action') id('$id')</h1></body></html>"; | |||||||||
| 30 | } | ||||||||||
| 31 | else { | ||||||||||
| 32 | 1 | return \404; | |||||||||
| 33 | } | ||||||||||
| 34 | } | ||||||||||
| 35 | } | ||||||||||
| 36 | |||||||||||
| 37 | 1 | Web::Machine->new( resource => 'YAPC::NA::2012::Example120::Resource' )->to_app; | |||||||||