summaryrefslogblamecommitdiff
path: root/lib/Net/HTTP/Console/Dispatcher/View.pm
blob: 5b52fc0a5b0ba5cecf1a0a4b4b236b207d1fa2d0 (plain) (tree)




















                                                                                
                                                                     





             
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->print( $_->[0] . ': ' . $_->[1]);
            }
        }
    }
}

1;