Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move code to appropriate role

  • Loading branch information...
commit e71a441a81f6f1d7e61fdb3c07e2f48ee10ba97d 1 parent 78fcbf5
@franckcuny authored
View
20 lib/Net/HTTP/Console.pm
@@ -4,7 +4,6 @@ our $VERSION = 0.01;
use MooseX::Declare;
class Net::HTTP::Console {
- use Try::Tiny;
with 'MooseX::Getopt';
with 'Net::HTTP::Console::Role::Headers';
@@ -16,25 +15,6 @@ class Net::HTTP::Console {
has url => (isa => 'Str', is => 'rw', predicate => 'has_url');
has format => (isa => 'Str', is => 'rw', predicate => 'has_format');
has format_mode => (isa => 'Str', is => 'rw', predicate => 'has_format_mode');
-
- method dispatch ($input) {
- my $result;
- try {
- foreach ($self->all_plugins) {
- last if ($result = $_->dispatch($input));
- }
- }catch{
- print "[ERROR]: ".$_;
- };
- }
-
- method new_anonymous_method ($http_method, $path) {
- $self->api_object->meta->add_net_api_method(
- 'anonymous',
- method => $http_method,
- path => $path,
- );
- }
}
1;
View
1  lib/Net/HTTP/Console/Dispatcher/HTTP.pm
@@ -30,7 +30,6 @@ class Net::HTTP::Console::Dispatcher::HTTP with Net::HTTP::Console::Dispatcher {
return 1;
}
-
method _do_request($http_method, $path) {
$self->application->new_anonymous_method($http_method, $path);
try {
View
7 lib/Net/HTTP/Console/Role/API.pm
@@ -30,6 +30,13 @@ role Net::HTTP::Console::Role::API {
$o;
}
+ method new_anonymous_method ($http_method, $path) {
+ $self->api_object->meta->add_net_api_method(
+ 'anonymous',
+ method => $http_method,
+ path => $path,
+ );
+ }
}
1;
View
13 lib/Net/HTTP/Console/Role/Plugins.pm
@@ -4,6 +4,8 @@ use MooseX::Declare;
role Net::HTTP::Console::Role::Plugins {
+ use Try::Tiny;
+
has dispatchers => (
is => 'rw',
isa => 'ArrayRef[Str]',
@@ -33,6 +35,17 @@ role Net::HTTP::Console::Role::Plugins {
\@p;
},
);
+
+ method dispatch ($input) {
+ my $result;
+ try {
+ foreach ($self->all_plugins) {
+ last if ($result = $_->dispatch($input));
+ }
+ }catch{
+ print "[ERROR]: ".$_;
+ };
+ }
}
1;
Please sign in to comment.
Something went wrong with that request. Please try again.