ious::Coder::JSON;
use strict;
use warnings;
use JSON::MaybeXS ();
use 5.010;
# ABSTRACT: JSON encoder for AutodataHandler
our $VERSION = '1.29'; # VERSION
sub coder
{
my $json = JSON::MaybeXS->n
essed;
my %coder = (
type => 'application/json',
format => 'json',
encode => sub { $json->encode($_[0]) },
decode => sub { $json->decode($_[0]) },
);
\%coder;
}
1;
__END_
_
=pod
=encoding UTF-8
=head1 NAME
Clustericious::Coder::JSON - JSON encoder for AutodataHandler
=head1 VERSION
version 1.29
=head1 AUTHOR
Original author: Brian Duggan
Current maintainer: Gr
ocalhost:1234' }];
YAML:
create_config_ok 'Foo', <<EOF;
---
url: http://localhost:1234
EOF
JSON:
create_config_ok 'Foo', <<EOF;
{"url":"http://localhost:1234"}
EOF
In addition to being a t
helper called 'parse_autodata' that handles incoming data by
Content-Type.
Supports application/json, text/x-yaml and
application/x-www-form-urlencoded (in-bound only).
When parse_autodata is calle
Accept header, the Content-Type header, or the default. (By
default, the default is application/json, but you can override that
too).
=head1 TODO
more documentation
handle XML with schemas
handl
';
use JSON::XS;
use YAML::XS qw/Dump Load/;
use Clustericious::Log;
my $default_decode = 'application/x-www-form-urlencoded';
my $default_encode = 'application/json';
my $json_encoder = JSON::XS->
Test::Mojo>, and add the following new attributes and methods.
=cut
use base 'Test::Mojo';
use JSON::XS;
use YAML::XS;
use File::Slurp qw/slurp/;
use Carp;
use List::Util qw(first);
use Clustericio
t = $t->testdata('filename');
Looks for filename, filename.json, filename.yaml in 't', 'data' or
't/data' directories. Parses with json or yaml if appropriate, then
returns the object.
=cut
sub
ml", "$_.json" }
map { $_, "t/$_", "data/$_", "t/data/$_" }
$filename;
my $content = slurp($filename) or croak "Missing $filename";
return decode_json($conten
cation/json" },
qq[{ "app": "<%= $class %>", "version" : "$<%= $class %>::VERSION" }])
->status_is(200, "posted version");
$t->get_ok('/clustericious/<%= $class %>')
->json_conten
s : given the plural of a table, look up the name of the class
The route that is created turns a JSON structure which is POSTed into
parameters for Rose::DB::Object::Manager::get_objects.
Additional
turns that
resultset to the client.
=cut
package Clustericious::RouteBuilder::Search;
use Mojo::JSON;
use Clustericious::Log;
use List::MoreUtils qw/uniq/;
use Data::Dumper;
use strict;
use Sub::Ex
ute;
use MojoX::Log::Log4perl;
use Log::Log4perl qw/:easy/;
use File::Temp;
use JSON::MaybeXS qw( encode_json decode_json );
use Carp qw( carp );
use Mojo::Util qw( monkey_patch );
# ABSTRACT: Constr
$meta && $meta->get("skip_existing");
$body = encode_json $arg;
$headers = { 'Content-Type' => 'application/json' };
} elsif (ref $arg eq 'CODE') {
$cb = $s
||= 'application/json';
if($body && ref $body eq 'HASH' || ref $body eq 'ARRAY')
{
$headers->{'Content-Type'} = 'application/json';
$body = encode_json $body;
}
r
Merge qw/merge/;
use Data::Dumper;
use Carp qw( croak );
use base qw( Exporter );
use JSON::MaybeXS qw( encode_json );
use Clustericious::Config;
# ABSTRACT: Helpers for clustericious config files.
o
r @mergeStack;
our @EXPORT = qw( extends_config get_password home file dir hostname hostname_full json yaml address public_address interface );
sub extends_config
{
my($name, @args) = @_;
push @
;
}
sub hostname_full
{
require Sys::Hostname;
Sys::Hostname::hostname();
}
sub json ($)
{
encode_json($_[0]);
}
sub yaml ($)
{
require YAML::XS;
local $YAML::UseHeader = 0;
my $str
$msg = $client->res->code." ".$client->res->default_message;
my $got = $client->res->json;
if ($got && ref $got eq 'HASH' and keys %$got==1 && $got->{text}) {
$msg = $client->res->code." ".$client->res->default_message;
my $got = $client->res->json;
if ($got && ref $got eq 'HASH' and keys %$got==1 && $got->{text}) {
alled" } = $sub };
$sub->($self);
}
package Clustericious::Config::Callback;
use JSON::MaybeXS qw( encode_json );
sub new
{
my($class, @args) = @_;
bless [@args], $class;
}
sub args { @{ sh
sub execute { '' }
sub to_yaml
{
my($self) = @_;
"!!perl/array:@{[ ref $self ]} @{[ encode_json [@$self] ]}";
}
package Clustericious::Config::Callback::Password;
use base qw( Clustericious::
=head1 DESCRIPTION
Clustericious::Config reads configuration files which are Mojo::Template's
of JSON or YAML files. There should generally be an entry for
'url', which may be used by either a clien
mplates;
use Mojo::ByteStream qw/b/;
use Data::Dumper;
use Clustericious::Log;
use Mojo::URL;
use JSON::XS;
use Scalar::Util qw/weaken/;
use Mojo::Base 'Mojolicious';
use File::HomeDir ();
use Cluste
HomeDir->my_home . "/etc", "/util/etc", "/etc" );
{
no warnings 'redefine';
sub Math::BigInt::TO_JSON {
my $val = shift;
my $copy = "$val";
my $i = 0 + $copy;
return $i;
}
}
=head2 $