blob: c72b09b71dfca36192986035065b5a23791b247e (
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
29
30
31
32
33
|
package Net::HTTP::Console::Dispatcher::Set;
use MooseX::Declare;
class Net::HTTP::Console::Dispatcher::Set with Net::HTTP::Console::Dispatcher {
method dispatch($input) {
(my $command, my $type, my $key, my $value) =
$input =~ /^([\w_]+)(?:\s([\w_]+))(?:\s([\w_]+))(?:\s(.*))?$/;
if ($command eq 'set') {
$self->_set_header($key, $value) if $type eq 'header';
}elsif($command eq 'unset') {
$self->_unset_header($key) if $type eq 'header';
}
}
method pattern($input) {
$input =~ /^(un)?set/ ? return $input : return 0;
}
method _set_header($header, $value) {
$self->application->set_header($header, $value);
$self->application->message("header $header set to $value");
}
method _unset_header($header) {
$self->application->delete_header($header);
$self->application->message("header $header unset");
}
}
1;
|