package MGA::Mirrors::Controller::Api; use Moose; use namespace::autoclean; BEGIN {extends 'Catalyst::Controller'; } =head1 NAME MGA::Mirrors::Controller::Api - 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::Api in Api.'); } sub list :Path :Args(1) { my ( $self, $c, $arg ) = @_; my ($product, $version, $arch) = $arg =~ m/^([^\.]+)\.(.+)\.([^\.]+)\.list$/; $c->log->debug("$product, $version, $arch"); my $list = $c->model('Mirrors')->find_distributions( { version => $version, arch => $arch, exists => 1, public => 1, } ); $c->stash->{current_view} = ''; $c->response->body(join("\n", map { my @tags; push(@tags, 'continent=' . $_->{ccode}) if ($_->{ccode}); push(@tags, 'zone=' . $_->{code}) if ($_->{code}); push(@tags, 'country=' . $_->{country}) if ($_->{country}); push(@tags, 'city=' . $_->{city}) if ($_->{city}); push(@tags, 'latitude=' . $_->{latitude}) if ($_->{latitude}); push(@tags, 'longitude=' . $_->{longitude}) if ($_->{longitude}); push(@tags, 'version=' . $version); push(@tags, 'version=' . $arch); push(@tags, 'type=' . 'distrib'); push(@tags, 'url=' . $_->{url}) if ($_->{url}); join(',', @tags); } @$list ) . "\n"); } =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;