me::HiRes qw(gettimeofday tv_interval);
use LWP::UserAgent;
use HTTP::Request::Common;
use JSON qw(decode_json);
use Try::Tiny;
# shorthand aliases:
sub lreq { (shift)->last_request }
sub lres { (shi
has 'ajax_request_headers', is => 'ro', default => sub {{
'X-RapidApp-RequestContentType' => 'JSON',
'X-RapidApp-VERSION' => $RapidApp::VERSION,
'X-Requested-With' => '
f it was generated by the
# RapidApp/ExtJS JavaScript client/browser to a JSON-encoded
# resource. Decodes and returns the JSON as perl ref
sub ajax_post_decode {
my ($self, $url, $params) = @_;
m
ct;
use warnings;
use Mojolicious::Lite;
use Plack::Builder;
use File::Spec ();
use JSON::MaybeXS qw( decode_json );
use YAML::XS qw( LoadFile );
use List::MoreUtils qw();
use POSIX ":sys_wait_h";
arams = {};
if ( defined( my $text_params_as_json = $c->req->param('text_params') ) )
{
$text_params = decode_json($text_params_as_json);
if ( ref($text_params) ne 'HASH' )
{
return "Invalid text_params - should be a JSON hash.\n";
}
elsif ( List::MoreUtils::any { ref($_) ne '' } values(%$text_params) )
{
return "Inval
is is returned by the C<content()> method of the Module class,
and is automatically serialized as JSON and returned to the client by the Module dispatch
system. Thus, it is possible to easily override
efined $self->focusField);
return $data;
}
sub customprompt_json {
my $self = shift;
return RapidApp::JSON::MixedEncoder::encode_json($self->customprompt_data);
}
sub writeResponse {
my ($self,
elf->customprompt_json);
#$c->response->status(500);
my $rct= $c->stash->{requestContentType};
if ($rct eq 'text/x-rapidapp-form-response' || $rct eq 'JSON') {
$c->stash->{json}= { success => \
0 };
$c->view('RapidApp::JSON')->process($c);
}
else {
unless (length($c->response->body) > 0) {
$c->response->content_type('text/plain; charset=utf-8');
$c->response->body("More user inpu
the
message to the user.
See RapidApp::Sugar for the "die usererr" syntax.
See RapidApp::View::JSON for the logic this module ties into.
=cut
# Note that this is considered text, unless it is an
esponse {
my ($self, $c)= @_;
$c->stash->{exception} = $self;
$c->forward('View::RapidApp::JSON');
}
sub stringify { (shift)->userMessage }
# This method exists because 'overload' doesn't do
$first_val;
$first_val = $value_list[0]->[0] if (defined $value_list[0]);
my $mapjs = encode_json(\%val_to_disp);
my $js = 'function(v){' .
'var val_map = ' . $mapjs . ';' .
'if(typeof val
use DateTime;
use DateTime::Format::Strptime;
use Module::Generic::File qw( tempfile );
use JSON;
use Net::IDN::Encode ();
use Nice::Try;
use Want;
our $VERSION = 'v0.1.0';
u
{file} = $base->child( 'public_suffix_list.txt' );
$self->{json_file} = Module::Generic::File->sys_tmpdir->child( 'public_suffix.json' );
$self->{meta} = {};
$self->{min_suffix} = 0;
$
w
if( $dont_have_etag && $meta->{etag} )
{
$self->save_as_json || return( $self->pass_error );
}
return( $self );
}
elsi
/uri_escape/;
sub new {
my $class = shift;
my (%param) = @_;
for my $required (qw/ua json_parser base_url opt doc/) {
die unless $param{$required};
}
bless { %param }, $cl
(%{$self->{opt}{body}}) {
$request->content_type('application/json');
$request->content($self->{json_parser}->encode($self->{opt}{body}));
} else {
$reques
return 1;
}
return $response->header('content-type') =~ m!^application/json!
? $self->{json_parser}->decode(decode_utf8($response->content))
: $response->content
$param->{ua} = $class->_new_ua;
}
unless (defined $param->{json_parser}) {
$param->{json_parser} = $class->_new_json_parser;
}
bless { %$param }, $class;
}
sub new_from_clien
equire JSON;
my $json = JSON->new->decode($content);
my ($client_type) = keys(%$json);
$class->new({
auth_uri => $json->{$client_type}->{auth_uri},
token_uri => $json->{$cl
{token_uri},
client_id => $json->{$client_type}->{client_id},
client_secret => $json->{$client_type}->{client_secret},
redirect_uri => @{$json->{$client_type}->{redirect_uris}}
objects that
overload it in some useful way:
use DateTime;
use JSON;
my $now = DateTime->now;
print encode_json { time => ~~$now };
=head2 Inchworm on a stick
~-
-~
Discove
ef, etc. Be advised
though that it will usually be serialized to JSON, so make sure anything you
put in it will be serializable as json.
=item $class->clear_from()
Resets the clear value to C<'*'>
$param->{ua} = $class->_new_ua;
}
unless (defined $param->{json_parser}) {
$param->{json_parser} = $class->_new_json_parser;
}
bless { %$param }, $class;
}
sub build {
my
die 'could not get service document.' . $res->status_line;
}
my $document = $self->{json_parser}->decode($res->content);
$self->build_from_document($document, $discovery_service_url,
::API::Method->new(
ua => $self->{ua},
json_parser => $self->{json_parser},
base_url => $base_url,
doc =
re APR::Request::Cookie;
}
use Cookie;
use Cookies::Domain;
use DateTime;
use JSON;
use Module::Generic::File qw( file );
use Module::Generic::HeaderValue;
use Nice::Tr
if( defined( $host ) && CORE::length( $host ) );
return( $name );
}
# Load cookie data from json cookie file
sub load
{
my $self = shift( @_ );
my $file = shift( @_ ) || return( $self->e
y $json = $f->load;
return( $self->pass_error( $f->error ) ) if( !defined( $json ) );
# No need to go further
if( !CORE::length( $json ) )
{
# $self->message( 3, "Cookie json f
| ctl | vb | resx |
v | vh | sv | vhd | vhdl | vim | yaml | yml |
xml | dtd | xslt? | ent | json | ini | Changes )$/ix) {
return "text";
}
if ($type =~ /^( jpe?g | gif | png | tiff? | i
not matching maching any of the above will just be passed on.
=cut
sub search{
return '
[% USE JSON ( pretty => 1 ) %]
[% DEFAULT o.size = "50" %]
[% DEFAULT o.field = "type" %]
[% DEFAULT o.fieldv
ze.json %],
"query": {
"bool": {
"must": [
{
"term": { [% o.field.json %]: [% o.fieldv.json %] }
},
{
"term": { [% o.field2.json %]: [% o.field2v.json %]
ountry ).json %]
}
},
[% END %]
[% IF o.region %]
{"query_string": {
"default_field": "geoip.region_code",
"query": [% aon( o.region ).json %]
::ESsearcher;
use 5.006;
use base Error::Helper;
use strict;
use warnings;
use Getopt::Long;
use JSON;
use Template;
use Search::Elasticsearch;
use Term::ANSIColor;
use Time::ParseDate;
=head1 NAME
EVAL_PERL=>1,
INTERPOLATE=>1,
POST_CHOMP=>1,
});
# inits JSON
$self->{j}=JSON->new;
$self->{j}->pretty(1); # make the output sanely human readable
$self->{j}->relax
load_elastic
This loads the currently specified config file
containing the Elasticsearch config JSON.
$ess->load_elastic;
=cut
sub load_elastic{
my $self=$_[0];
if ( ! $self->errorblank )
not matching maching any of the above will just be passed on.
=cut
sub search{
return '
[% USE JSON ( pretty => 1 ) %]
[% DEFAULT o.size = "50" %]
[% DEFAULT o.field = "type" %]
[% DEFAULT o.fieldv
e.json %],
"query": {
"bool": {
"must": [
{
"term": { [% o.field.json %]: [% o.fieldv.json %] }
},
{"query_string": {
"default_field": [% o.field2.json %
": [% o.field2v.json %]
}
},
[% IF o.country %]
{"query_string": {
"default_field": "geoip.country_code2",
"query": [% aon( o.country ).json %]
}
($rv, $device_id) = $connection->DiscoveryFind($device_address);
=head3 DiscoveryGet
my ($rv, $json) = $connection->DiscoveryGet($device_id);
=head1 REPORTING BUGS
Please report bugs at L<https:/
not matching maching any of the above will just be passed on.
=cut
sub search{
return '
[% USE JSON ( pretty => 1 ) %]
[% DEFAULT o.program = "postfix" %]
[% DEFAULT o.facility = "mail" %]
[% DEFAU
logstash-*",
"body": {
"size": [% o.size.json %],
"query": {
"bool": {
"must": [
{
"term": { [% o.field.json %]: [% o.fieldv.json %] }
},
[% IF
.json %]
}
},
[% END %]
[% IF o.hostx %]
{"query_string": {
"default_field": "host.keyword",
"query": [% o.hostx.json
t char *device_id)
PPCODE:
const char *props_json;
int rv = ziAPIDiscoveryGet(conn, device_id, &props_json);
mXPUSHi(rv);
if (rv == 0)
mXPUSHp(props_json, strlen(props_json));