summary refs log tree commit diff
path: root/lib/Net/HTTP/Console/Dispatcher/View.pm
blob: bfc50f0ce17b6d07ac89c2ed0dfddfe94e1cb44c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package Net::HTTP::Console::Dispatcher::View;

use MooseX::Declare;

class Net::HTTP::Console::Dispatcher::View with Net::HTTP::Console::Dispatcher {

    method pattern ($input) {
        $input =~ /^show/ ? return $input : return 0;
    }

    method dispatch ($input) {
        (my $key) = $input =~ /^show ([\w]+)/;

        if ($key eq 'headers') {
            $self->application->_show_last_headers;
        }
        elsif ($key eq 'content') {
            $self->application->_show_last_content;
        }
        elsif ($key eq 'defined_headers') {
            foreach ($self->application->all_headers) {
                $self->application->message( $_->[0] . ': ' . $_->[1]);
            }
        }
    }
}

1;