summary refs log tree commit diff
path: root/lib/Net/HTTP/Console/Role/DefaultMethod.pm
blob: c8f858e3164d01a3a9b2b33c9c8cb0d837a10b80 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package Net::HTTP::Console::Role::DefaultMethod;

use Moose::Role;
use JSON;
use Method::Signatures::Simple;
use namespace::autoclean;

with qw/Net::HTTP::Console::Role::HTTP/;

method from_lib {
    my $input = shift;
    $input =~ /^(\w+)\s(.*)$/;
    my $method = $1;
    my $args   = $2;
    my $o      = $self->lib->new();
    my ($content, $response) = $o->$method(%{JSON::decode_json($args)});
    $self->_set_and_show($content, $response);
}

1;