diff options
Diffstat (limited to 'lib/MGA/Mirrors/Controller/Mirrors.pm')
-rw-r--r-- | lib/MGA/Mirrors/Controller/Mirrors.pm | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/lib/MGA/Mirrors/Controller/Mirrors.pm b/lib/MGA/Mirrors/Controller/Mirrors.pm new file mode 100644 index 0000000..5d07ca5 --- /dev/null +++ b/lib/MGA/Mirrors/Controller/Mirrors.pm @@ -0,0 +1,66 @@ +package MGA::Mirrors::Controller::Mirrors; +use Moose; +use namespace::autoclean; + +BEGIN {extends 'Catalyst::Controller'; } + +=head1 NAME + +MGA::Mirrors::Controller::Mirrors - Catalyst Controller + +=head1 DESCRIPTION + +Catalyst Controller. + +=head1 METHODS + +=cut + + +=head2 index + +=cut + +sub index :Path :Args(0) { + my ( $self, $c ) = @_; + + $c->response->body('Matched MGA::Mirrors::Controller::Mirrors in Mirrors.'); +} + +sub mirror :Path :Args(1) { + my ( $self, $c, $host ) = @_; + $c->stash->{hostname} = $host; + + if ($c->req->param('hostinfo')) { + my $hinfo = $c->model('Mirrors')->find_mirrors({ + hostname => $host, + })->[0]; + if (! $hinfo->{readonly}) { + $c->model('Mirrors')->add_or_update_host($host, + bandwidth => $c->req->param('bandwidth'), + city => $c->req->param('city'), + country => $c->req->param('country'), + syncfrom=> $c->req->param('syncfrom'), + ); + } + } + + $c->stash->{host} = $c->model('Mirrors')->find_mirrors({ + hostname => $host, + })->[0]; +} + +=head1 AUTHOR + +Olivier Thauvin + +=head1 LICENSE + +This library is free software. You can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut + +__PACKAGE__->meta->make_immutable; + +1; |