enerates lib/MIME/DB.pm for a given mime-db version
##
use strict;
use warnings;
use JSON::XS qw(decode_json);
# changelog: https://github.com/jshttp/mime-db/releases
my $cmd = join(" ", $0,
db.json', $tag;
my $url = sprintf 'https://cdn.jsdelivr.net/gh/jshttp/mime-db@%s/db.json', $tag;
print STDERR "getting $url\n";
my $json = `curl -k -f -s $url` || die;
my $db = decode_json($
urce url: https://cdn.jsdelivr.net/gh/jshttp/mime-db@v1.52.0/db.json
use constant version => 'v1.52.0';
sub data { {'application/mud+json',{source=>'iana',compressible=>1},'application/vnd.commonspace
>['hpgl']},'application/vnd.motorola.flexsuite',{source=>'iana'},'application/vnd.coreos.ignition+json',{compressible=>1,source=>'iana'},'application/vnd.kodak-descriptor',{source=>'iana',extensions=>
,{source=>'iana'},'application/dssc+der',{extensions=>['dssc'],source=>'iana'},'application/dicom+json',{compressible=>1,source=>'iana'},'application/gxf',{source=>'apache',extensions=>['gxf']},'model
= '0.003'; # VERSION
use parent 'Alien::Base';
use File::Which qw(which);
use IPC::Run ();
use JSON ();
use Path::Tiny ();
sub bin_dir {
my ($class) = @_;
if ( $class->install_type eq 'sys
o');
if ($kaleido) {
my $decode_json_safe = sub {
my ($out) = @_;
my $data;
eval { $data = JSON::decode_json($out); };
$@ = '' if ($@);
( not $data and not $t->is_expired ) {
$h->pump;
$data = $decode_json_safe->($out);
}
$h->finish;
};
if ($@) {
warn
ancer::Hook;
use Dancer::Logger;
use Dancer::Renderer;
use Dancer::Route;
use Dancer::Serializer::JSON;
use Dancer::Serializer::YAML;
use Dancer::Serializer::XML;
use Dancer::Serializer::Dumper;
use D
er_version
debug
del
dirname
info
error
engine
false
forward
from_dumper
from_json
from_yaml
from_xml
get
halt
header
headers
hook
layout
load
load_app
logger
error
set
setting
set_cookie
session
splat
status
start
template
to_dumper
to_json
to_yaml
to_xml
true
upload
captures
uri_for
var
vars
warning
);
# Dancer's syn
qw(show_plot);
use Chart::Plotly::Plot;
use Chart::Plotly::Image;
use Data::Munge qw(elem);
use JSON;
use List::AllUtils qw(pairmap pairwise uniq);
use Module::Load;
use Types::Standard qw(HashRef I
yout{$axis_name} = {
range => $range,
zeroline => JSON::false,
autorange => JSON::false,
(
( not defined $el_axis_title or $el_a
text or $el_axis_text->is_blank )
? ( showticklabels => JSON::false, )
: ( showticklabels => JSON::true, )
),
(
( not defined $e
:pdl);
our $VERSION = '0.002003'; # VERSION
with qw(Chart::GGPlot::Backend::Plotly::Geom);
use JSON;
use List::AllUtils qw(max pairmap);
use Module::Load;
use Chart::GGPlot::Backend::Plotly::Util
=> $marker,
line => $line,
notched => ( $params->at('notch') ? JSON::true : JSON::false ),
notchwidth => $params->at('notchwidth'),
hoverinfo => ( $flip ?
m L<Dancer2::Session::DatabasePlugin>
=item L<Dancer2::Session::DBIC>
=item L<Dancer2::Session::JSON>
=item L<Dancer2::Session::Memcached>
=item L<Dancer2::Session::MongoDB>
=item L<Dancer2::Sess
re JSON;
my $kaleido = File::Which::which('kaleido');
if ($kaleido) {
my $decode_json_safe = sub {
my ($out) = @_;
my $data;
eval { $data = JSON::d
ecode_json($out); };
$@ = '' if ($@);
return $data;
};
my @cmd = ( $kaleido, 'plotly', '--disable-gpu', '--no-sandbox' );
eval {
require Ch
( not $data and not $t->is_expired ) {
$h->pump;
$data = $decode_json_safe->($out);
}
$h->finish;
};
if ($@) {
warn
package OpenAPI::Render;
use strict;
use warnings;
use Clone qw( clone );
use JSON qw( decode_json );
use version;
# ABSTRACT: Render OpenAPI specifications as documents
our $VERSION = '0.3.0'; # V
raw JSON or parsed data structure, constructs a C<OpenAPI::Render> object.
Does not modify input values.
=cut
sub new
{
my( $class, $api ) = @_;
if( ref $api ) {
# Parsed JSON give
ing will modify it.
$api = clone $api;
} else {
# Raw JSON given, need to parse.
$api = decode_json $api;
}
my $self = { api => _dereference( $api, $api ) };
cer provides helpers to
serialize and deserialize for the following data formats:
=over 4
=item JSON
=item YAML
=item XML
=item Data::Dumper
=back
To activate this feature, you only have to set
he
format you require, for instance in your config.yml:
serializer: JSON
Or right in your code:
set serializer => 'JSON';
From now, all HashRefs or ArrayRefs returned by a route will be seri
# set the status
$response->content_type('application/json');
Dancer::SharedData->response->content_type('application/json');
Set or get the status of the current response object.
=hea
g it into some 8bit
charset, for example).
Also, since automatically serialized JSON responses have
C<application/json> Content-Type, you should always encode them by
hand.
Can also be set with envi
ritten
with plugin setting 'content_type'.
Here is example to use JSON:
plugins:
'Ajax':
content_type: 'application/json'
=head1 AUTHOR
This module has been written by Alexis Sukrieh <
# don't create a new serializer unless it's defined in the config
# (else it's created using json, and that's *not* what we want)
my $serializer_name = Dancer::App->current->setting('serializ
$serializer_name);
return;
}
sub init {
my ($class, $name, $config) = @_;
$name ||= 'JSON';
$_engine = Dancer::Engine->build('serializer' => $name, $config);
return $_engine;
}
#
e:
serializer: "YAML"
Or in the application code:
# setting JSON as the default serializer
set serializer => 'JSON';
In your routes you can access parameters just like any route.
When
package Dancer::Serializer::JSONP;
our $AUTHORITY = 'cpan:SUKRIA';
$Dancer::Serializer::JSONP::VERSION = '1.3521';
# ABSTRACT: serializer for handling JSONP data
use strict;
use warnings;
use Dancer:
:JSON';
sub serialize {
my $self = shift;
my $callback = Dancer::SharedData->request->params('query')->{callback};
my $json = $self->SUPER::serialize(@_);
return $callback . '(' . $json
zer::JSONP - serializer for handling JSONP data
=head1 VERSION
version 1.3521
=head1 SYNOPSIS
=head1 DESCRIPTION
This class is a subclass of L<Dancer::Serializer::JSON> with support for JSONP.
I
n the author tests (in F</xt>) against the built code.
=item $ dzil listdeps --json
List all the dependencies, in JSON.
=item $ dzil build --notgz
Build the code, but don't generate the tarball.
VERSION
version 1.3521
=head1 SYNOPSIS
my $engine = Dancer::Engine->build( Serializer => 'JSON', $configuration );
=head1 DESCRIPTION
Dancer has various engines such Serializer engines, Temp
t it inherits from this
class.
=head1 ATTRIBUTES
=head2 name
The name of the engine, such as I<JSON>, or I<Simple>.
=head2 type
The type of the engine, such as I<Serializer>, or I<Session>.
=hea
text/html' => 'YAML',
'text/xml' => 'XML',
'text/x-json' => 'JSON',
'application/json' => 'JSON',
};
my $loaded_serializer = {};
my $_content_type;
sub template_or_se
}
if $params && $params->{content_type};
}
push @content_types, 'application/json';
# remove duplicates
my %seen;
return [ grep { not $seen{$_}++ } @content_types ];
from the URL
=item
the B<accept> from the request headers
=item
The default is B<application/json>
=back
The content-type/serializer mapping that C<Dancer::Serializer::Mutable>
uses is
ser
ded_files = qw(
pm_to_blib Makefile META.yml Build pod2htmd.tmp META.json
pod2htmi.tmp Build.bat .cvsignore MYMETA.json MYMETA.yml
);
sub import {
my $self = shift;
my $caller = cal
an example of a route handler that will return a HashRef
use Dancer;
set serializer => 'JSON';
get '/user/:id/' => sub {
{ foo => 42,
number => 100234,
list
ot
the case by default - Dancer renders the response via the current
serializer.
Hence, with the JSON serializer set, the route handler above would result in a
content like the following:
{"numb
ey dynamically depend on
Perl modules you may not have on your system.
=over 4
=item B<JSON>
requires L<JSON>
=item B<YAML>
requires L<YAML>
=item B<XML>
requires L<XML::Simple>
=item B<Mutabl