| 1 | package HTTP::Balancer::Command::Add::Host; | ||
| 2 | 1 | ▶ | use Modern::Perl; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | with qw(HTTP::Balancer::Role::Command); | |
| 5 | |||
| 6 | has name => ( | ||
| 7 | is => "rw", | ||
| 8 | traits => [ 'NoGetopt' ], | ||
| 9 | 0 | ▶ | default => sub { shift->argv(2) }, |
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||
| 10 | 1 | ); | |
| 11 | |||
| 12 | 1 | has fullname => ( | |
| 13 | is => "rw", | ||
| 14 | isa => "Str", | ||
| 15 | metaclass => "Getopt", | ||
| 16 | cmd_aliases => "f", | ||
| 17 | default => "", | ||
| 18 | documentation => "full virtual host name used to filter requests. default: empty string. make sure only one host has empty fullname.", | ||
| 19 | ); | ||
| 20 | |||
| 21 | 1 | has address => ( | |
| 22 | is => "rw", | ||
| 23 | isa => "Str", | ||
| 24 | metaclass => "Getopt", | ||
| 25 | cmd_aliases => "a", | ||
| 26 | default => "0.0.0.0", | ||
| 27 | documentation => "the address this virtual host listens to. default: 0.0.0.0", | ||
| 28 | ); | ||
| 29 | |||
| 30 | 1 | has port => ( | |
| 31 | is => "rw", | ||
| 32 | isa => "Str", | ||
| 33 | metaclass => "Getopt", | ||
| 34 | cmd_aliases => "p", | ||
| 35 | default => "80", | ||
| 36 | documentation => "the TCP port this host listens to. default: 80", | ||
| 37 | ); | ||
| 38 | |||
| 39 | 0 | ▶ | sub ordinary_args { |
|
Subroutine
ordinary_args: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 40 | 0 | qw(name); | |
| 41 | } | ||
| 42 | |||
| 43 | 0 | ▶ | sub run { |
|
Subroutine
run: not called CC=1 SCAR=6.9
Pod
undocumented
| |||
| 44 | 0 | my ($self, ) = @_; | |
| 45 | |||
| 46 | 0 | my @columns = grep {!/^id$/} $self->model("Host")->columns; | |
| 47 | |||
| 48 | 0 | my %params; @params{@columns} = @$self{@columns}; | |
| 49 | |||
| 50 | 0 | $self | |
| 51 | ->model("Host") | ||
| 52 | ->new(%params) | ||
| 53 | ->save; | ||
| 54 | } | ||
| 55 | |||
| 56 | 1 | 1; | |