Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #688 from metacpan/mickey/reverse_deps_ep
Added new /reverse_dependencies API endpoints
- Loading branch information
Showing
3 changed files
with
192 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package MetaCPAN::Server::Controller::ReverseDependencies; | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Moose; | ||
|
||
BEGIN { extends 'MetaCPAN::Server::Controller' } | ||
|
||
__PACKAGE__->config( namespace => 'reverse_dependencies' ); | ||
|
||
with 'MetaCPAN::Server::Role::JSONP'; | ||
|
||
sub dist : Path('dist') : Args(1) { | ||
my ( $self, $c, $dist ) = @_; | ||
my $data = $c->model('CPAN::Release')->reverse_dependencies($dist); | ||
$c->detach('/not_found') unless $data; | ||
$c->stash($data); | ||
} | ||
|
||
sub module : Path('module') : Args(1) { | ||
my ( $self, $c, $module ) = @_; | ||
my @params = @{ $c->req->params }{qw< page page_size sort >}; | ||
my $data = $c->model('CPAN::Release')->raw->requires( $module, @params ); | ||
$c->detach('/not_found') unless $data; | ||
$c->stash($data); | ||
} | ||
|
||
1; |