self->redirect( .... );
return $self->to_yaml( .... );
return $self->to_json( .... );
# or just return a raw arrayref
return [ 200 , [ 'Content-type
ler);
use URI;
use URI::Query;
use LWP::UserAgent;
use Plack::Middleware::OAuth::AccessToken;
use JSON::Any;
use warnings;
use strict;
sub build_args {
my ($self,$code) = @_;
my $config = $se
sponse->header('Content-Type');
my $atkn;
if( $content_type =~ m{json} || $content_type =~ m{javascript} ) {
my $params = JSON::Any->new->decode( $response_content );
$atkn = Plack::Midd
warnings;
use strict;
use parent qw(Plack::Middleware::OAuth::UserInfo);
use LWP::UserAgent;
use JSON;
sub query {
my $self = shift;
# my $gh = $self->create_handle;
my $ua = LWP::UserA
m( access_token => $self->token->access_token );
my $response = $ua->get( $uri );
my $body = $response->decoded_content;
return unless $body;
return decode_json( $body ) || { };
}
1;
;
use strict;
use parent qw(Plack::Middleware::OAuth::UserInfo);
use LWP::UserAgent;
use URI;
use JSON::Any;
sub query {
my $self = shift;
my $ua = LWP::UserAgent->new;
my $uri = URI->new
s_token ,
'max-results' => 0,
'alt'=> 'json',
);
my $res = $ua->get($uri);
warn $res->decoded_content;
return JSON::Any->new->decode($res->decoded_content) if $res->is_
warnings;
use strict;
use parent qw(Plack::Middleware::OAuth::UserInfo);
use LWP::UserAgent;
use JSON;
# use Net::GitHub;
sub create_handle {
my $self = shift;
# return Net::GitHub->new( acc
ate_handle;
my $ua = LWP::UserAgent->new;
my $uri = URI->new( 'https://github.com/api/v2/json/user/show' );
$uri->query_form( access_token => $self->token->access_token );
my $respons
e = $ua->get( $uri );
my $body = $response->decoded_content;
return unless $body;
my $obj = decode_json( $body ) || { };
return $obj->{user};
}
1;
warnings;
use strict;
use parent qw(Plack::Middleware::OAuth::UserInfo);
use LWP::UserAgent;
use JSON;
sub query {
my $self = shift;
my $ua = LWP::UserAgent->new;
my $uri = URI->new( 'h
$self->token->access_token );
my $response = $ua->get( $uri );
my $body = $response->decoded_content;
return unless $body;
my $obj = decode_json( $body ) || {};
return $obj;
}
1;
nericHandler;
use parent qw(Plack::Request);
use warnings;
use strict;
use YAML::Any;
use JSON::Any;
our $json_any;
sub run {
my $self = $_[0];
# get method or post method ?
my $res;
ntent_type { 'text/html' }
sub to_json {
my ($self, $obj) = @_;
$json_any ||= JSON::Any->new;
return $self->render( $json_any->encode($obj) , 'text/json' );
}
sub to_yaml {
my ($sel
ng )
=head2 render( $body | String , $content_type | String )
=head2 to_yaml( $obj )
=head2 to_json( $obj )
=head2 post
POST handler, abstract method.
=head2 get
GET handler, abstract method.