Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Added new /reversedependencies API endpoints
Added 2 new endpoints: * /reverse_dependencies/dist/DISTRIBUTION moved query from WEB * /reverse_dependencies/module/MODULE copied (& later will remove) current /release/requires endpoint Added a new controller Controller/ReverseDependencies.pm to later replace the current Controller/Search/ReverseDependencies.pm (will be removed with all supporting code once WEB is set to point to new 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 ); | ||
return unless $data; | ||
$c->stash($data); | ||
} | ||
|
||
1; |