t::Util 'any';
use Hash::Util 'lock_hashref_recurse';
use constant JSONSTR => 'application/json';
use constant JSONRE => qr/^${\JSONSTR}/;
use constant XHRRE => qr/^XMLHttpRequest$/i;
our @ajax_head
0]) ? 1 : 0
}
method maybe_ajax (@headers) {
$self->is_xhr
|| $self->env->{HTTP_ACCEPT} =~ JSONRE
|| any { $self->header($_) } (@ajax_headers, @headers)
}
method is_xhr { ($self->header('X
$$column{type} //= 'TEXT';
$$column{sql_type} = 'TEXT'
if $$column{type} eq 'JSON';
$$column{sql_type} = 'INTEGER'
if $$column{type} eq 'Time::Moment';
y);
use JSON::MaybeXS;
use Data::Dumper;
use Time::Piece;
use Plack::Util;
use Module::Metadata;
use Syntax::Keyword::Dynamically;
use Syntax::Keyword::Try;
our @EXPORT = qw(dmsg json __pkgfn
} @ENV{qw'FRAME_DEBUG DEBUG'};
#sub _json_default {
# JSON::MaybeXS->new( utf8 => 1, $dev_mode ? ( pretty => 1 ) : () );
#}
const our $json_default => JSON::MaybeXS->new( utf8 => 1, $DEV_MODE ?
RT_DOES;
$^H{ __PACKAGE__ . '/user' } = 1;
field $app : weak : param : accessor = undef;
field $json;
field $debug_mode :param :accessor = $DEBUG_MODE;
field $dev_mode :param :accessor = $DEV_MODE;
ontroller : does(Frame::Base);
use utf8;
use v5.40;
use Carp;
use Encode;
use Text::Xslate;
use JSON::MaybeXS;
use Feature::Compat::Try;
use Frame::Request;
use Const::Fast;
const our @EXPORT_DOES
$content_type ||= "application/json; charset=$opts{charset}";
try {
$res->content_type($content_type);
$res->body( json->encode($content) )
}
s => $status, msg => $content }
if ( $content_type // $req->maybe_ajax ) =~ Frame::Request::JSONRE;
$self->render( $content, $status, $content_type, @args );
}
method render_500 ( $content